cosmicvoid
Master
I guess you are running under linux of some sort, and I've not done any programming in that OS. Here is what I do in my Windoze apps:
Open the COMn: port as a file type of stream, with at least a 1K rx buffer.
Start a thread whose purpose is to poll the rx buffer status. When the thread finds more than 0 characters waiting in the rx buffer, it reads them one by one and calls the parse function, with a byte as the argument. This way, the rx buffer gets emptied quickly, so there is no overflow.
The parse function is a state machine, which looks for the elements of a packet. Any byte which fails validation for the state is tossed and the state machine starts over at state 0. So, possibly 1 packet will be discarded until it syncs up to a packet boundary, then it should stay in sync and see all packets unless there is data corruption.
The best I can do is give you a sample in C or C++, if that would help.
Open the COMn: port as a file type of stream, with at least a 1K rx buffer.
Start a thread whose purpose is to poll the rx buffer status. When the thread finds more than 0 characters waiting in the rx buffer, it reads them one by one and calls the parse function, with a byte as the argument. This way, the rx buffer gets emptied quickly, so there is no overflow.
The parse function is a state machine, which looks for the elements of a packet. Any byte which fails validation for the state is tossed and the state machine starts over at state 0. So, possibly 1 packet will be discarded until it syncs up to a packet boundary, then it should stay in sync and see all packets unless there is data corruption.
The best I can do is give you a sample in C or C++, if that would help.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.