# Communication Settings This document configures CAN, CAN FD, and RS485 communication parameters in protocol mode. In passthrough mode, no separate configuration command is needed: select the RS485 baud rate when opening the RS485 serial port, and configure the CAN network interface when bringing up SocketCAN. | Connection | Configuration location | After power-up | | --- | --- | --- | | USB management serial port | Send `AT+` commands through the management port | Saved settings remain active | After connecting the board, Windows shows two `SANPO Studio Management Port` serial ports, one for each STM32 MCU. STM32 (1) controls CAN-1/2 and RS485-1/2; STM32 (2) controls CAN-3/4 and RS485-3/4. Send `AT+` commands as text and set the line ending to `CRLF`. Do not send the characters `\r\n` as ordinary payload data. ## Factory Defaults | Item | Default | | --- | --- | | Classic CAN | 1 Mbps | | CAN FD arbitration phase | 1 Mbps | | CAN FD data phase | 5 Mbps | | RS485 | 4 Mbps, 1 stop bit, no parity, 8 data bits | | SPI | SHORT, 23 bytes | ## Configure CAN and CAN FD ```text AT+SETFDCAN=, ``` The first parameter is used by classic CAN and by the CAN FD arbitration phase. The second parameter is used only by the CAN FD data phase. | Parameter | Supported values | | --- | --- | | Arbitration phase | `1000000`, `500000`, `250000`, `125000`, `100000` | | Data phase | `2000000`, `3000000`, `4000000`, `5000000` | All four CAN FD data rates use exact bit timing with 0% error. For example, set classic CAN/CAN FD arbitration to 1 Mbps and CAN FD data to 5 Mbps: ```text AT+SETFDCAN=1000000,5000000 ``` Successful response: ```text OK ``` Query the current values: ```text AT+SETFDCAN? ``` Example response: ```text FDCAN:1000000,5000000 ``` The setting applies to both CAN/CAN FD interfaces on the current MCU and is saved to Flash. Repeating `AT+SETFDCAN=` with the currently saved values does not write another Flash record. If a matching FDCAN controller was stopped when its gs_usb or SocketCAN interface was closed, the command restores the stopped live FDCAN so that management-port protocol mode or SPI protocol mode can continue. A FDCAN controller that is already running is not reinitialized. ## Configure RS485 ```text AT+SETRS485=,,, ``` | Parameter | Supported values | | --- | --- | | Baud rate | `2400` to `4000000`, `5000000`, `6000000`, and `7500000` | | Stop bits | `1` or `2` | | Parity | `0` none; `1` odd; `2` even | | Data bits | `8` or `9` | For example, configure the common Unitree motor setting of 4 Mbps, 8-N-1: ```text AT+SETRS485=4000000,1,0,8 ``` Query the current values: ```text AT+SETRS485? ``` Example response: ```text RS485:4000000,1,0,8 ``` Send this command through a management port. It applies to both RS485 interfaces on the current MCU and is saved to Flash. `AT+SETRS485?` reports the saved protocol-mode setting. Linux enumeration of a dedicated RS485 passthrough port may configure the physical UART, so after that port has been opened at another baud rate, the live UART setting may differ from the queried value. In protocol mode, send an explicit `AT+SETRS485=` command after opening the management port to restore the required setting. ## Restore Communication Defaults ```text AT+CFGERASE ``` The successful response is `OK`. The command restores the factory communication parameters listed on this page. It clears saved CAN/CAN FD, RS485, SPI mode, RAW-target, and power-on automatic-execution settings, but does not delete offline batches. If repeated configuration changes return `ERR,5`, use this command to clear the communication configuration area and configure the required values again. ## Troubleshooting | Symptom | Action | | --- | --- | | No response to a setting command | Send text and terminate it with `CRLF` | | `ERR,1` or `ERR,3` | Check the number and range of parameters | | `ERR,5` | The configuration area is full; run `AT+CFGERASE` and configure again | ## Appendix: Configure SPI Mode ```text AT+SPIMODE? AT+SPIMODE=SHORT AT+SPIMODE=LONG ``` | Mode | SPI transfer size | Use | | --- | ---: | --- | | SHORT | 23 bytes | Classic CAN; up to 18 bytes of RS485 data | | LONG | 73 bytes | Classic CAN, CAN FD; up to 68 bytes of RS485 data | After a successful switch, the command returns `OK`. The SPI host must stop the current transfer, wait at least 10 ms, and then use the new fixed transfer length. Applications are recommended to send the required command explicitly to both management ports at every startup.