SerialDataEventListener dataReceived - when is this event fired?

16 views
Skip to first unread message

Andy Beck

unread,
Dec 24, 2019, 12:11:46 PM12/24/19
to Pi4J
We are using the Pi4J Serial API for reading packets of data from our device.  These packets can vary in length from 6 to 20 bytes and are sent about once every 2 seconds.  We've configured the project to add a "SerialDataEventListener' and have overridden the "dataReceived" function.  

My question is, what causes the "dataReceived" listener to be called.  It doesn't appear to be called on receipt of every character, because I usually receive the entire packet when I do a get? Is it time-based? For example, if no character is received in n milliseconds.  

Frank Delporte

unread,
Dec 25, 2019, 4:00:25 AM12/25/19
to Pi4J
Hello, not sure in your case, but most of the times this is done by ending a message with a 0-byte (0x00 or /0) so the receiver knows this is the end of the data.

Frank
Reply all
Reply to author
Forward
0 new messages