armadsen / ORSSerialPort

Serial port library for Objective-C and Swift macOS apps
MIT License
751 stars 183 forks source link

Hex Received data is not continuous #186

Closed sonwa closed 2 years ago

sonwa commented 2 years ago

Hi, Sometimes the received data is not continuous.

image

sonwa commented 2 years ago

Serial device data length is 5, and sometimes data is received separately. Not the complete received data.

armadsen commented 2 years ago

Hi @sonwa. This is expected behavior. The underlying serial port hardware, the driver, and ORSSerialPort itself have no way of knowing what "complete" means for your data. Serial data isn't intrinsically structured, it's just a stream of bytes delivered as the port receives them.

In order to help you solve this, ORSSerialPort includes a packet parsing API. You can find information about how to use it on this Wiki page: https://github.com/armadsen/ORSSerialPort/wiki/Packet-Parsing-API. Let me know if you have questions as you start using it.