SANPO USB to FDCAN
SANPO USB to FDCAN sends and receives CAN FD standard and extended frames through USB serial, with up to 64 data bytes per frame. Firmware always enables BRS for transmitted CAN FD frames.
For classic CAN, see SANPO USB to CAN. To use standard Linux canX interfaces, see SocketCAN.
Connection and Setup
Open the USB serial port for the target MCU.
Send
AT+SETFDCAN?and confirm that arbitration and data-phase bitrates match the bus.To change them, send
AT+SETFDCAN=<arbitration>,<data>as text withCRLF.Send complete frames from this page in hexadecimal or binary mode.
Factory defaults are 1 Mbps arbitration and 5 Mbps data. See Communication Settings for supported values.
Select a CAN FD Channel
Current USB port |
Channel |
Target |
|---|---|---|
Port for CAN-1/2 |
|
CAN-1 |
Port for CAN-1/2 |
|
CAN-2 |
Port for CAN-3/4 |
|
CAN-3 |
Port for CAN-3/4 |
|
CAN-4 |
Either USB port |
|
Both CAN FD interfaces on the current MCU |
For transmission, 1/3 select the first local interface and 2/4 select the second. Replies only use local Channel 1/2.
Data Length Code
CAN FD supports only these length codes:
Code |
Data bytes |
Code |
Data bytes |
|---|---|---|---|
|
0 |
|
8 |
|
1 |
|
12 |
|
2 |
|
16 |
|
3 |
|
20 |
|
4 |
|
24 |
|
5 |
|
32 |
|
6 |
|
48 |
|
7 |
|
64 |
The actual data length must match the code.
CAN FD Extended Frame
Transmit and receive use the same format:
Field |
Length |
Description |
|---|---|---|
Header |
2 bytes |
Fixed |
Channel |
1 byte |
CAN FD interface number |
CAN ID |
4 bytes |
29-bit extended ID, most significant byte first |
Length code |
1 byte |
|
Data |
0 to 64 bytes |
Size selected by the length code |
Tail |
2 bytes |
Fixed |
Send 16 bytes to extended ID 0x1F100101 on Channel 1:
45 46 01 1F 10 01 01 0A
01 01 01 01 42 00 00 00 01 01 64 00 78 56 34 12
0D 0A
0A selects 16 data bytes.
CAN FD Standard Frame
Field |
Length |
Description |
|---|---|---|
Header |
2 bytes |
Fixed |
Channel |
1 byte |
CAN FD interface number |
Reserved |
2 bytes |
Fixed |
CAN ID |
2 bytes |
11-bit standard ID, most significant byte first |
Length code |
1 byte |
|
Data |
0 to 64 bytes |
Size selected by the length code |
Tail |
2 bytes |
Fixed |
Send 12 bytes to standard ID 0x142 on Channel 2:
53 46 02 00 00 01 42 09
01 02 03 04 05 06 07 08 09 0A 0B 0C
0D 0A
Parse Replies
Motor feedback returns in the same SF or EF format. Use the header to identify standard or extended frames, the length code to determine data size, and Channel to identify the first or second local interface.
USB is a byte stream. One serial read() may return part of a frame, one frame, or multiple frames. Parse continuously using the header and length code rather than assuming each read returns exactly one frame.
Troubleshooting
Symptom |
Action |
|---|---|
Classic CAN device does not reply |
Use |
CAN FD device does not reply |
Check arbitration bitrate, data bitrate, BRS, termination, and CAN FD support on the peer |
Invalid transmit length |
Use only 0 to 8, 12, 16, 20, 24, 32, 48, or 64 bytes |
Reply Channel only shows 1/2 |
Replies use local numbering; this is normal |
Multiple frames arrive together |
Parse continuously by header, length code, and tail rather than serial read boundaries |