Closed evanzulli closed 5 years ago
It looks like you are mixing two types of incompatible reading methodologies. If you are receiving SerialPortEvent.LISTENING_EVENT_DATA_RECEIVED, then all data is already read for you by the framework, and you simply access it using the getReceivedData()
method of the SerialPortEvent
object that is passed to your serialEvent()
callback. If you want to use InputStreams, then you either need to not use event-based reading or only use event notifications for LISTENING_EVENT_DATA_AVAILABLE (not for LISTENING_EVENT_DATA_RECEIVED).
could you give some example snippet about getReceivedData() @hedgecrw ?? Thank you
Example snippets are all available in the Usage Wiki: https://github.com/Fazecast/jSerialComm/wiki/Usage-Examples
Specifically: https://github.com/Fazecast/jSerialComm/wiki/Event-Based-Reading-Usage-Example
Closing due to no issue, wrong event type being used.
Hi! My code receives the event but when i try to read from InputStream there is nothing to read. byteBuffer[0] = 0 says there is something but is.available() returns 0. What am I doing wrong? Thanks