Question about ofSerial - readBytes()

I’m currently trying to get my sensor values(0~4000) from arduino to OF.

I tried readByte() but it only grabs 0~255 so I tried readBytes() from above link.

I copy&pasted the code to ofApp::update() and error keeps occurs.

it says I can’t use bytesRequired inside
“unsigned char bytes[bytesRequired];”

int bytesRequired = 8;
unsigned char bytes[bytesRequired];
int bytesRemaining = bytesRequired;

some sort of same naming problem? I cant really understand because I don’t have much knowledge in programming…

How can I make this example work?

Hi @quinton , have you looked at the serialExample (in the folder /examples/communication/)? It might be a bit easier to learn from a working application than from the code example in the documentation.

1 Like

This example ofxSerial/examples/intermediate/buffered_serial_device/line_buffer at master · bakercp/ofxSerial · GitHub

might be helpful. It requires the ofxSerial and ofxIO and ofxPoco (included) addon.


thank you I’ve tried modifying examples and got the solution!