Skip to content

Conversation

Bwooce
Copy link

@Bwooce Bwooce commented Jul 20, 2025

Summary

  • Add automatic detection of SLCAN adapter ACK/NACK support
  • Handle adapters that don't provide ACK/NACK confirmations
  • Improve transfer reassembly and cleanup for better frame handling
  • Rely on natural serial backpressure instead of artificial delays

Technical Details

  • ACK/NACK Detection: Auto-detect adapter capabilities by sending invalid command and checking for NACK response
  • Transfer Management: Improved cleanup of incomplete transfers with shorter timeouts
  • Backpressure: Remove artificial 2ms delays and rely on natural serial connection flow control

There was a problem where CANable (canable.io) adaptors do not support ACK/NACK responses.  This has been a known issue since 2019 (normaldotcom/canable-fw#8) and remains unresolved and unavailable in the prebuilt firmwares.

This change:
  - Auto-detects if adapter supports ACK/NACK responses using invalid 'X' command on init. No response = not supported, NACK = supported.
  - Implements length-based message parsing for adapters without ACK/NACK. This probably should apply regardless as all messages have a known size, but let's not upset the applecart.
  - Maintains backward compatibility with existing adapters
  - Adds robust message framing that handles concatenated messages properly
  - Stores ACK/NACK support state in memory for device lifetime

 This resolves the issue of dronecan gui not working with off-the-shelf canable.io adapters, especially the combination of non-linux use where candlelight firmware (gs_usb) is not supported under macos and the only alternative is canable firmware, which...doesn't support ACK/NACK.

tested with:
- Single messages with/without data
- Multiple concatenated messages
- Partial messages (incomplete reads)
- Messages with timestamps
- Extended CAN frames
- CAN-FD frames
@Bwooce
Copy link
Author

Bwooce commented Jul 22, 2025

Hmm, let me test this more. I appear to be flooding the bus in dronecan_gui, so something has changed in a negative way.

@Bwooce
Copy link
Author

Bwooce commented Jul 26, 2025

Right, #88 is a pre-requisite to avoid flooding the bus.

@Bwooce Bwooce changed the title Add ACK/NACK auto-detection support for SLCAN adapters Add SLCAN ACK/NACK auto-detection support Jul 27, 2025
- Remove artificial delays, rely on natural serial backpressure
- Improve RetrySerial to preserve ACK/NACK detection state
- Add cleaner debug logging controls
- Compatible with adapters that don't support ACK/NACK confirmations
@Bwooce Bwooce force-pushed the slcan-ack-nack-support branch from 0db9c0f to 2a1f5cf Compare July 27, 2025 10:38
@Bwooce
Copy link
Author

Bwooce commented Jul 27, 2025

Tested and working well for me on a DSDTECH SH-C30A on macOS using DroneCAN GUI. I've tried to avoid any AI slop appearing in here, and I've manually tested quite a bit against ArduPilot.

The periodic scheduler was referencing callback_running but never defining it,
causing NameError when GUI tries to spin the node. Added missing variable
initialization to prevent callback overlap.
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

Successfully merging this pull request may close these issues.

1 participant