I just recently opened up an old sketch that I used to control some outdoor led lighting I installed. New computer, fresh download of Adruino 1.0.
This is my first run in with Arduino 1.0 so it took me a long time to troubleshoot the sketch that was based around Serial.available() > 96 to control 32 rgb leds. It took my a while to strip everything away, download an older ide, and test in the serial monitor.
I'm trying to figure out what exactly the difference is between the two ide's for the following code and use case.
Arduino 0023 > serial monitor > enter and send "1" before Serial.available max out at 127
Arduino 1.0 > serial monitor > enter and send "1" before Serial.available max out at 63
I didn't see anything in the release notes about a specific change in Serial.available, only that the communication is now asynchronous. I feel like I must be missing something obvious. How do I read 96 bytes out of the buffer in Arduino 1.0?
Thanks, I was wondering if it was something like that. Looks like I'll be switching to a serialEvent scheme. I'm wondering what the speed implications will be.
I'll now be doing more executions per Serial.read() then when I was reading 96 in a loop.
What values are you sending that need to be ints, rather than bytes?
values[valueIndex++] = Serial.read();
Oh, I see. None.
Arduino 0023 > serial monitor > enter and send "1" before Serial.available max out at 127
Arduino 1.0 > serial monitor > enter and send "1" before Serial.available max out at 63
Serial data is buffered. The size of the buffer is different, since outgoing serial data is now buffered, too. To minimize the impact, the incoming and outgoing buffers occupy the same space that the incoming buffer used to.
The key to processing serial data is to not wait for all the data to be buffered before you start reading it.
Read and store in another location as soon as the data arrives.
Keep in mind that serial data delivery is not guaranteed. You should not expect a packet to be "the next 96 bytes". You WILL get out of sync if you make that assumption.
PaulS:
Serial data is buffered. The size of the buffer is different, since outgoing serial data is now buffered, too.
Haven't made the switch yet, kinda hanging on for a patch. But it's a powerful incentive knowing that short serial output shouldn't take as long with 1.0.
That is true but running 0022 I understand that when I do Serial.print(some_string), my code will wait until all those characters have been taken before my next instruction executes. Without a buffer, that means each being sent off at the Serial baud rate before the next is taken. With a buffer and a string no longer than the buffer, the characters will be taken at fill the buffer speed which I believe should be magnitudes faster than 9600 baud.
I should be more clear. It shouldn't take as long at the send end where IMO speed is more critical.