creativearmenia / as3-arduino-connector

Automatically exported from code.google.com/p/as3-arduino-connector
0 stars 0 forks source link

Incorrect bytes are send when using _arduinoConnector.writeBytes #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Incorrect bytes are send when using _arduinoConnector.writeBytes and they seems 
to be random each time I run the application

What steps will reproduce the problem?
Use _arduinoConnector.writeBytes and pass byteArray ec.

var b:ByteArray = new ByteArray();
b.writeInt(1);
_arduinoConnector.writeBytes(b);

What is the expected output? What do you see instead?
Correct byte should be send to com port

What version of the product are you using? On what operating system?
1.5

Please provide any additional information below.
1. I am using Advanced Serial Data Logger to check what bytes where send to com 
port.
2. Obly bypass I found is to send bytes one by one using writeByte

Original issue reported on code.google.com by i...@voyda.eu on 1 Oct 2013 at 9:44

GoogleCodeExporter commented 9 years ago
Generally it seems that there is something wrong with biteArray writing and 
reading
http://code.google.com/p/as3-arduino-connector/issues/detail?id=25

but hopefully for now we can use loop

Read - temporary fix for read readBytesAsByteArray()
var byteArray:ByteArray = new ByteArray();

            while(_arduinoConnector.bytesAvailable)
            {
                byteArray.writeByte(_arduinoConnector.readByte());
            }

Write - temporary fix for writeBytes ()
var sent:Boolean = true;
            for (var i:uint = 0; i < byteArray.length; i++) 
            {
                var byteSent:Boolean = _arduinoConnector.writeByte(byteArray[i]);
                sent = sent && byteSent;
            }

            trace('sent status: ' + sent);

Original comment by i...@voyda.eu on 1 Oct 2013 at 10:18