bufferUntil() won't trigger serialEvent()
in
Core Library Questions
•
1 year ago
I can't get bufferUntil() to trigger a serialEvent() call.
I've whittled my code down to bare bones- just setting up the serial port and looking for the byte. If I remove the bufferUntil(), serialEvent() triggers on every receive. If I do a check for the data value bufferUntil() should be looking for inside my serialEvent() (see code below), the program clearly sees and responds to that value, so I don't think it's an issue with the format of my data coming in.
I'm on Win7 with Processing 1.5.1; I've resolved the RXTX mismatch warning. The odd thing is, not that long ago, I had an application using bufferUntil() that worked on this computer.
Has anyone else experienced, heard of, or fixed this issue?
Mike
EDIT: The serial data source is an Arduino doing a Serial.write(0xFF), along with some other stuff. The content I see in the serial monitor suggests that the right data is coming across.
- // EXTREMELY minimalist bufferUntil() test code- adapted from Tom Igoe's code on the bufferUntil() ref page.
- import processing.serial.*;
- Serial myPort;
- int inVal = 0;
- int endbyte = 255;
- void setup() {
- myPort = new Serial(this, Serial.list()[0], 57600);
- myPort.bufferUntil(endbyte); // if we comment this line out, things work SWIMMINGLY. Otherwise, serialEvent() never runs.
- }
- void draw(){}
- void serialEvent(Serial myPort) {
- inVal = (myPort.read());
- if (inVal == endbyte) println("GROG!!!");
- println(inVal);
- }
1