c - A way to convert byte stream to packet stream in C89 on an embedded device -
I am working with an embedded device that connects to PC rs232 (rs232 on USB).
I am thinking of developing my own protocol:
& lt; Magic & gt; & Lt; LENGTH & gt; & Lt; Binari Data & gt; & Lt; CRC & gt;
But I do not want to modify the wheel again.
Please note note that: I am thinking of a much restricted device: 4kb of RAM, no kernel, and no standard cobb.
Can you think of a standard way (perhaps Open Source Library) to do this?
If you do any best practice in the code of your own solution?
- Do you also use magic byte at the end of the package?
- Is it better to use time intervals instead of delimiter?
- How can you get started with the package in a stream binary data?
- Is it better to use Text Protocol?
Update: Please read the question. I should not ask for the library, but for good practice.
See details about a simple protocol. / P>
To respond to your specific points:
- "magic" bytes at the end of the packet do not do any harm, but if you already know that How long is the packet should be, and the CRC should be.
- It may be sensible for the specified time period, so if there is a large difference between the bytes within a packet, an error has been flagged. After use, I am not sure of the value of using the delimiter based on the deadline.
- Do you mean, "How can you find the beginning of packets in a stream of binary data"? If this is the case, then perhaps specify the minimum difference between the packet, and / or the recipient needs a single note after each packet.
- This makes it easy for debugging, and no special software is required on PC, but very efficient. Of course, if text-based is more important than the usability efficiency compared to the system, then it is perfectly appropriate.
Comments
Post a Comment