I need (to design?) a protocol for communication between a microprocessor-driven data logger, and a PC (or similar) via serial connection. There will be no control lines, the only way the device/PC can know if they're connected is by the data they're receiving. Connection might be broken and re-established at any time. The serial connection is full-duplex. (8n1)
The problem is what sort of packets to use, handshaking codes, or similar. The microprocessor is extremely limited in capability, so the protocol needs to be as simple as possible. But the data logger will have a number of features such as scheduling logging, downloading logs, setting sample rates, and so on, which may be active simultaneously.
My bloated version would go like this: For both the data logger and PC, a fixed packet size of 16 bytes with a simple 1 byte check sum, perhaps a 0x00 byte at the beginning/end to simplify recognition of packets, and one byte denoting the kind of data in the packet (command / settings / log data / live feed values etc). To synchronize, a unique "hello/reset" packet (of all zero's for example) could be sent by the PC, which when detected by the device is then returned to confirm synchronization.
I'd appreciate any comments on this approach, and welcome any other suggestions as well as general observations.
Observations: I think I will have to roll my own, since I need it to be as lightweight as possible. I'll be taking bits and pieces from protocols suggested in answers, as well as some others I've found... Slip, PPP and HLDC.
USB (Universal Serial Bus) is widely protocol with different versions and speeds. A maximum of 127 peripherals can be connected to a single USB host controller. USB acts as "plug and play" device. The USB are used in almost devices such as keyboards, printers, media devices, cameras, scanners and mouse.
A protocol is an agreement between two parties about how the two parties should behave. A communication protocol is a protocol about how two parties should speak to each other. Serial communication protocols assume that bits are transmitted in series down a single channel.
Wiring and Hardware. A serial bus consists of just two wires - one for sending data and another for receiving. As such, serial devices should have two serial pins: the receiver, RX, and the transmitter, TX. It's important to note that those RX and TX labels are with respect to the device itself.
There are two broad types of serial communication: synchronous and asynchronous. There are a very large number of different standards and protocols for serial communication, ranging from the very simple to the seriously complicated.
You can use Google's Protocol Buffers as a data exchange format (also check out the C bindings project if you're using C). It's a very efficient format, well suited to such tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With