jamesmunns / postcard-rpc

An RPC layer for postcard based protocols
Apache License 2.0
76 stars 14 forks source link

Don't use CDC-ACM #1

Closed jamesmunns closed 5 months ago

jamesmunns commented 10 months ago

Adam suggested that I just use raw USB transport, rather than re-framing over COBS.

I probably want a few "transport" options, such as some kind of embedded-io-async or something "any bidi serial", in addition to "raw transport on embassy-usb".

jamesmunns commented 10 months ago

From @adamgreig:

https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/usb_raw_bulk.rs is henrik_alser's

i wrote https://github.com/embassy-rs/embassy/blob/main/examples/stm32f4/src/bin/usb_raw.rs originally which uses control transfers which have a built in u16 "command" and "value" field, and optional buffer of data either way after that

but in embassy it's probably simpler to just make a bulk endpoint both ways and do that instead, which is what's in that first example from the application point of view you just have an async write() and async read() functions that shuttle data around, and you send/receive a slice of arbitrary length (i.e. it's framed)

though somewhat annoyingly in embassy as-is I don't think you can send like a header and then some payload and have it be part of the same trasnfer

jamesmunns commented 10 months ago

Definitiely keep an eye on https://github.com/kevinmehall/nusb/issues/3

jamesmunns commented 10 months ago

3 opens the door to this for potentially supporting other backends, so we can experiment with nusb or other methods.