I am using newsoftserial8 at 9600 baud on a 328 under v15; this loop is supposed to read a character from an applet on the xport and reply; instead it goes into an infinite loop and keeps receiving characters when no more are being sent.
I wouldn't expect there to be any trouble at 9600 baud, even with Arduino 0015. Perhaps an occasional corrupted byte at 14.4K or higher, but certainly not continuous flow of bytes. Can you describe your problem in a little more detail?
You realize, of course, that you are sending a '1' and a '2' to the soft serial port every iteration through the loop, whether or not a character is received?
I will play with this code and see were the problem was exactly - I don’t see why sending 1 and 2 out should affect input counts in available(). The applet code is:
header[0] = ‘1’; // send request for ROM value
gtp.send(header);
header = gtp.receive();
if (header[0] == ‘1’)
{
System.out.println(“got 1 back”);
msgbody = gtp.receive();
msgbodystring = new String(msgbody);
System.out.println(“got " + msgbodystring + " after that”);
address.setText(msgbodystring);
}
else
System.out.println(“got garbage”);
where gtp is a Java socket i/o handler and is called only once.
Ooops - spoke too soon: now I don’t get the ‘2’ back from newsoftserial.