import flash.events.*;
import flash.net.Socket;
var serial:String;
//Create a socket connection to the deafult tinkerProxy port
var arduinoSocket:Socket = new Socket("localhost",5334);
arduinoSocket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
function readResponse():void
{
serial = arduinoSocket.readUTFBytes(arduinoSocket.bytesAvailable);
touch(serial);
}
function socketDataHandler(event:ProgressEvent):void
{
readResponse();
}
and at arduino is a simple
println("1000000000000000")
trace(serial);
}
and at arduino is a simple
println("1000000000000000")
trace(serial);
}
No, that is not the code on the Arduino. Try again.
Then, you need to understand how serial data transmission works. The data is sent one byte at a time. Slowly.
Your PC app reads all the serial data that has arrived, and assumes that that is a complete packet. It is not. When you consider ways to delimit the packets being sent, and read and store data until a complete packet arrives, your problems will be solved.
How to do that only comes up about 3 times a week on the forum, so it might take you a few seconds to find some solutions.
PaulS:
How to do that only comes up about 3 times a week on the forum, so it might take you a few seconds to find some solutions.
Please dont do this. At least give a hint or a example link. I know how you hate repeating yourself, of course. Me too. But here are reading also non-native english speaker like me and I had a hard time finding a thread like this that has the same problem like me, and now I'm again stuck, as I dont know what I have to search for in the forum. This thread describes my problem and you just end it with a blind alley.
Can you please give me a pointer or terms I can use to find those 3-times-a-week-threads? :~