Skip to content
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

Re-evaluate the serial framing protocol #18

Open
clalancette opened this issue Feb 28, 2019 · 2 comments
Open

Re-evaluate the serial framing protocol #18

clalancette opened this issue Feb 28, 2019 · 2 comments

Comments

@clalancette
Copy link
Contributor

clalancette commented Feb 28, 2019

The current serial protocol is exactly equivalent to the one in https://github.com/PX4/px4_ros_com/blob/master/templates/microRTPS_transport.cpp#L151 . However, it is worthwhile to explore whether that is the best way to frame a serial protocol. Some observations and thoughts on serial framing design:

  1. The payload should be a well-known format. We are using CDR.

  2. There should be a header with a well-known sequence, a length at the beginning, and a CRC. We are currently using CRC16. The current protocol looks like this (the vertical bars are separators and not actually part of the protocol):

    >>>|topic_ID|seq|len_high|len_low|CRC_high|CRC_low|payload_start...payload_end|

  3. Currently sends and receives to the serial port are "send it and forget it". It might be nice to have an ACK/NACK response.

  4. Currently, messages that are larger than the ring buffer in the serial->ROS2 direction are just quietly dropped. It might be nice to have the ability to query for the largest size message that we accept. Aternatively, see 3 above.

  5. We may want to think about using byte-stuffing for the serial protocol (see https://eli.thegreenplace.net/2009/08/12/framing-in-serial-communications/). In particular, think about the case where one of the first three > gets garbled in transmission, but there is >>> somewhere in the body of the message. In that case, we'll essentially be taking "random" data as the sequence, length, and CRC, and may make us do something unintended.

  6. Even better, maybe we should look at using COBS instead: https://www.embeddedrelated.com/showarticle/113.php

@clalancette
Copy link
Contributor Author

This has partially been done by implementing COBS as an alternative in #33 . However, we still want to investigate whether we can use DDS-XRCE as another framing protocol: https://www.omg.org/spec/DDS-XRCE/

@tfoote
Copy link
Collaborator

tfoote commented Mar 21, 2019

After some review the XRCE is much more powerful. It brings a much larger set of functionality to the embedded side. It's likely that microROS can provide that eventually. it provides a lot of things like acks for message reception, transport reliability functions. But you also have to have data readers, data writers etc all implemented on the microcontroller side. In the long term adding a ROS 2 abstraction on top of XRCE is likely something that will be possible but in the short term the simpler serial protocol will likely prove effective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants