-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Note on wider applicability and compatibility #10
Comments
Ditto! This library rocks. I used it on a Maple Mini clone, where it builds just fine with platformio. The other end was a Raspberry Pi running the python COBS implementation. My code is at igor47/spaceboard specifically in https://github.com/igor47/spaceboard/blob/master/src/main.cpp (for the C++ code) and https://github.com/igor47/spaceboard/blob/master/spaceteam/microcontroller.py (for the python) and is probably a nice example of two-way comms between the two languages. my application was to drive a ws281x led strip (hard to do on a raspberry pi) and using cobs i was able to efficiently transfer big chunks of data for setting large number of led colors at once. |
I just added a note in the README pointing back here. It's a nice idea! Thanks for the feedback. |
This library, along with the python COBS library is outstanding. The COBS implementation provides encoding and decoding to for fast, robust binary data transfer between an Arduino and python on a PC or Raspberry Pi. I'm getting 14 floating point numbers at 100Hz from an Arduino using 115200 baud. The most difficult part of sending binary data over serial is figuring out the beginning and end of each message, or frame. Sending COBS-encoded messages makes that very straightforward when reading in python using The example Arduino sketch below gathers an array of floats, encodes with COBS and sends the binary result over serial:
The python script below reads the incoming serial stream searching for the zero-byte, which COBS ensures is not in the data portion of the packets. Locating the zero-byte indicates the end of the packet. It then (1) decodes the COBS-encoded message and (2) converts the binary array of characters back into floating point numbers with
Both sender and receiver files are attached. |
Here's a round-trip example over serial from a microcontroller like Arduino or ESP32:
and:
The python example from @igor47 above helped clarify how to handle the terminating character. Without that terminating character the It works like a champ using the python COBS library. The demo sends and received 5 floating-point numbers. Arduino or ESP32 receiver-sender code:
Python sender-receiver code. Upload Aduino or ESP32 sketch then let it reboot and listen on the serial port. Then run this to send 5 floats and listen for the return message with the same 5 floats:
|
Hi all, The example comes with a companion Python app that works as a remote control and data collector. We distribute it as an example showing high-speed data capture for the Arduino Nicla Sense ME over UART/USB. |
Hello, I'm doing something similar between a Pi Pico and a python application on my PC. I really love the simple interface of your library. It works like a charm. 👍 |
Thanks for the great library! Just a couple of points that could be in the documentation if desired.
For those looking to use this library with other boards and other serial interfaces here is the approach I used. I applied this to a Feather M0 board which has an additional Serial1 interface defined.
Outside of any functions:
Inside of the Arduino
setup()
method:Note 1: I used PacketSerial on Serial1 while using still using Serial for debugging output and such. So unless I read your code wrong, it seems that one can apply PacketSerial to some serial interfaces and not others based on how one wants to use the serial interface.
Note 2: I experienced full compatibility of the COBS implementation with a nice Python COBS implementation receiving data from PySerial. These folks have a good reference to the COBS Transactions on Networking (TON) paper.
Once again thanks for the library!
Cheers
Greg
The text was updated successfully, but these errors were encountered: