SANPO USB to CAN

The SANPO USB to CAN protocol controls CAN devices from Windows or Linux and forwards CAN data without requiring an additional driver. The raw CAN frame is wrapped with a SANPO header and trailer for transmission over the USB management serial port. These extra bytes are used only by the board; the CAN device receives the raw CAN frame without a SANPO header or trailer.

For SANPO USB to CAN FD, see SANPO USB to FDCAN.

Connection

After connecting the board over USB, six USB serial ports appear. Two management ports carry this protocol; Windows normally displays them as SANPO Studio Management Port. One management port accesses CAN-1/2 and the other accesses CAN-3/4. The other four ports are independent RS485 serial ports. COM and /dev/ttyACM* numbering is not guaranteed to follow the board silkscreen; initially connect only one CAN device to confirm the mapping.

On Linux, you can run the Python serial-port identification example to identify the two management ports.

CAN Extended Frame

Send and receive use the same format:

Field

Length

Description

Header

2 bytes

Fixed 45 54, or ET

Channel

1 byte

CAN interface number

CAN ID

4 bytes

29-bit extended ID, big-endian

Data length

1 byte

0 to 8

CAN data

0-8 bytes

Must match the preceding length

Trailer

2 bytes

Fixed 0D 0A

Send 8 data bytes to Channel 1 with extended ID 0x0000FD01:

45 54 01 00 00 FD 01 08 01 02 03 04 05 06 07 08 0D 0A

CAN Standard Frame

Send and receive use the same format:

Field

Length

Description

Header

2 bytes

Fixed 53 54, or ST

Channel

1 byte

CAN interface number

Reserved

2 bytes

Fixed 00 00

CAN ID

2 bytes

11-bit standard ID, big-endian

Data length

1 byte

0 to 8

CAN data

0-8 bytes

Must match the preceding length

Trailer

2 bytes

Fixed 0D 0A

Send 4 data bytes to Channel 2 with standard ID 0x142:

53 54 02 00 00 01 42 04 11 22 33 44 0D 0A

Xiaomi CyberGear Example

Example program: USB to CAN CyberGear example

Windows example:

python usb2can_cybergear_demo_v8.py --port COM8 --motors 1 --channel 1

Linux example:

sudo python3 usb2can_cybergear_demo_v8.py --port /dev/ttyACM0 --motors 1 --channel 1

Adjust the serial port, interface, and motor ID for the actual installation.

Troubleshooting

Symptom

Action

USB serial port cannot be found

Check the USB cable, power for the control section, and reconnect the board

No reply after sending

Check the USB port mapping, Channel, CAN ID, bit rate, termination resistors, wiring, and device power

The frame is sent to both CAN interfaces

Channel is 0x00; select a specific channel

Reply Channel differs from board CAN-3/4

Replies use local 1/2 numbering on the current MCU; this is normal

Reply format differs from this page

Send AT+ET as text, wait for OK, and retry