1
\$\begingroup\$

Suppose a random Arduino board has its serial pins connected to a random USB-serial bridge (like, but not necessarily, a CP2102). Assume further that the PC at the other end of the USB cable is using a library like jSerialComm (https://fazecast.github.io/jSerialComm/), and the baudrate is something like 250kbps-8N1.

Ignoring for a moment the possibility of bit errors being introduced between the USB bridge chip and AVR itself, is there any actual need to rigorously validate bits received by the Arduino over the USB serial link? Or can it be reasonably assumed that the USB bus itself is essentially error-free (automatically detecting errors and retransmitting if necessary)?

AFAIK, USB has several transmission modes... some automatically detect errors and retransmit when necessary, and others (mainly the bulk transfer modes) just spray bits and leave it up to higher-level software to detect and correct errors. What I'm NOT sure about is which level the Arduino USB serial drivers are actually using ;-).

\$\endgroup\$
7
  • 2
    \$\begingroup\$ never assume anything \$\endgroup\$
    – jsotola
    Commented Feb 23, 2022 at 23:52
  • \$\begingroup\$ Can you guarantee the hardware is perfect without any problems, all connections are correct and valid, that the moon came up on the right side of the sun. If you can unconditionally guarantee that then maybe. \$\endgroup\$
    – Gil
    Commented Feb 24, 2022 at 0:39
  • \$\begingroup\$ No, but at some point, if you push the paranoia TOO far, you end up with radically-multiplying failsafe complexity and diminishing returns that approach zero & will drive you recursively mad. I know there are 4 main USB operating modes... control, interrupt, bulk, and isochronous. If a Nano tethered to a Windows PC is using one of the first 3 USB modes, the USB bus itself is effectively error-free. What I'm NOT sure about is which USB mode something like a Nano's CP2102, or a Leonardo's on-die USB, is actually USING. \$\endgroup\$
    – Bitbang3r
    Commented Feb 24, 2022 at 2:34
  • \$\begingroup\$ What messages are being sent from PC to Arduino? Human-typed terminal messages? Or automated ones? If human, just add echoes and make it so the Arduino ignores messages that don't make sense. If automated then it depends on the message. Whether it's one-shot and if missing it matters or if a similar message will be sent again soon and can be waited for. A bad plug into the board or connector can make you get gibberish and things like that. It might also just miss the message for some reason. \$\endgroup\$
    – DKNguyen
    Commented Feb 24, 2022 at 4:32
  • 2
    \$\begingroup\$ From own experience using binary protocols to communicate with (different types of) Arduino boards, I have never seen a problem with corrupted data. I've also never seen the code upload verification to fail (which happens by default during sketch upload). So I assume for practical purposes, it can be assumed the serial link is error-free. \$\endgroup\$
    – PMF
    Commented Feb 24, 2022 at 6:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.