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

[communication] Revive Asynchronous Multi-Node Bus (AMNB) protocol #395

Merged
merged 2 commits into from
Jul 31, 2020

Conversation

salkinium
Copy link
Member

@salkinium salkinium commented May 6, 2020

A flexible multi-node bus using p-persistent CSMA/CD over a shared wired medium.
This can work with using UART with differential signalling (typically CAN transceivers for automatic direction control) or without for short distances with TX in Open-Drain mode with an external pull-up, for some STM32 even just using a single pin via the built-in half-duplex mode for UART.

Consider this a low-cost alternative to I2C, with the goal to be more stable, more flexible and faster.

@salkinium
Copy link
Member Author

salkinium commented May 6, 2020

Design goals:

  • important information (address, command, type) in the header first, so I can discard the message if it's not for me.
  • very little overhead for small messages, here CRC8 can protect (max 256 bits => 32 bytes incl. header).
  • support large payloads via CRC16 (max 2^16 bits => 8kB).
  • small payload header is compatible with large payload header, requiring only the first 4 Bytes to decide if its a small or large payload, and max 32 Bytes to decide whether the heade is valid (because small payload is part of the header CRC8).
  • to have the payload in a continous memory to be able to reinterpret_cast the payload on-device to whatever the type is, to avoid explicit serialization just like in XPCC. This requires 4-bytes alignment of both payloads.
  • Simply "filling" the values on the wire into the packed message struct is enough. This involves a choosing a layout that avoids unaligned access for Cortex-M0, requiring 2-bytes alignment for uint16_t and 4-bytes alignment for uint32_t pointers.
  • Option to convert payload into shared_ptr, which requires only copying small payloads and because the large payloads are already allocated on the heap anyways.
  • Delegating memory management to the application or at least the node, so the protocol stack doesn't require any buffers and only operates on messages owned somewhere else.

The C++ api is still WIP and currently untested.

@dergraaf You're a protocol wizzard, would you mind giving some feedback?
@rleh @chris-durand @se-bi I'm using this for the ELVA semaphores, but perhaps this interesting for RCA use-cases too?

@salkinium
Copy link
Member Author

Things that really bug me: There seems to be no way in the UART hardware to indicate whether a symbol is currently being received. All the RX flags are only set after the full symbol has been received. This feature could turn the "Collision Detection" into a "Collision Avoidance", which would be a nice stretch goal.

@salkinium salkinium force-pushed the feature/amnb branch 4 times, most recently from 30d4b3e to e50bee8 Compare May 15, 2020 13:05
@salkinium salkinium force-pushed the feature/amnb branch 3 times, most recently from 6d896e7 to e70c8c9 Compare June 1, 2020 19:40
@salkinium salkinium force-pushed the feature/amnb branch 7 times, most recently from 16ce934 to 8f496b4 Compare June 8, 2020 00:45
@salkinium salkinium force-pushed the feature/amnb branch 6 times, most recently from 775960a to 170c9e3 Compare June 10, 2020 17:30
@salkinium salkinium force-pushed the feature/amnb branch 2 times, most recently from 07bcbda to f49901f Compare June 12, 2020 00:45
@salkinium salkinium marked this pull request as ready for review June 12, 2020 05:06
@salkinium
Copy link
Member Author

I'll add documentation and AVR examples at a later stage.

@salkinium salkinium merged commit 8820d6b into modm-io:develop Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants