I am trying to use the serialEvent() routine so that any time i receive 9 bytes in the serial buffer serialEvent() will execute and i can dump the data into a buffer. Something like the following code.
void setup() {
Serial.begin(9600);
Serial.buffer(9); //setup serialEvent() to call only once there is 9 bytes in buffer
}
void serialEvent() {
for(i = 0; i < 9; i++) {
// get the new byte:
combuff = (char)Serial.read(); } Problem is either i am doing it wrong or serial.buffer() no longer exists or works. Is this the case? does Serial.bufferUntil() no longer work as well? Any help would be appreciated. Thanks Tay
I am trying to use the serialEvent() routine so that any time i receive 9 bytes in the serial buffer serialEvent() will execute and i can dump the data into a buffer. Something like the following code.
In what version of the IDE?
Problem is either i am doing it wrong or serial.buffer() no longer exists or works. Is this the case?
When did that ever work?
The serialEvent() method was added for 1.0. There is not, and, as far as I know, never has been, a buffer() method.
one the serialEvent() description page it says the following.
Description
Called when data is available. Use Serial.read() to capture this data. The serialEvent() can be set with Serial.buffer() to only trigger after a certain number of data elements are read and can be set with Serial.bufferUntil() to only trigger after a specific character is read.
Instead of looking for a delimiter (like newline) you count bytes. Same general idea.
The documentation does not necessarily fully, completely or correctly describe what the current version does (unfortunately, but documentation has a habit of doing that). Really you need to search the libraries (which are supplied) and see for yourself what actually is done and in what way. You could try to lodge a "documentation error" report, but so far when I have done that I have been ignored. Maybe I did it in the wrong place, but I don't know what the right place is.