Quote:
|
Originally Posted by SWFKIT
E.g. The "querymodem" script in the "querymodem" sample, the last line is
Code:
commx.writeStr(command);
You can change it to
Code:
var stream = new StringStream;
stream.write(command);
commx.write(stream);
The "stream" object contains the binary data and is sent by the "write" method.
Similarly, in the "initialize" script, the "onRXChar" event handler is
Code:
var str = this.readStr(count);
FlashPlayer.setVariable("response.text", str);
trace(str);
It can be changed to
Code:
var stream = this.read(count);
FlashPlayer.setVariable("response.text", stream.toString());
trace(stream);
The "read" method returns a stringstream object contains binary data.
|
But somehow the stream length not equal to count length.
Code:
var stream = this.read(count);
FlashPlayer.setVariable("response.text", stream.toString());
trace(stream);
It can be changed to (Example count -> HEX 2,39,47,C8,3,42,35)
Code:
var HexString;
var DecString;
commx.onRxChar = function (count) {
var getStreamByte = this.read(count);
streamByte = getStreamByte;
for(i=0; i<streamByte.length; i++) {
var Dec = streamByte.get(); //
var Hex = Dec.format("%X"); //
HexString = HexString + "," + Hex; //
DecString = DecString + "," + Dec; //
}
FlashPlayer.setVariable("response.text", HexString + "\n");
FlashPlayer.setVariable("response.text", FlashPlayer.setVariable("response.text") + DecString + "\n");
}