How longan-labs/serial_can_bus works
This repository is an Arduino serial-to-CAN firmware paired with a CAN Bus Shield driver. Its principal workflow accepts serial input, handles either AT-style configuration or binary CAN frames, and in data mode transmits frames or returns received frames over serial. Configuration includes serial/CAN rates and CAN masks and filters, persisted in EEPROM. The driver configures the MCP2515 and performs CAN message I/O over SPI. The README contains no capability details, and the main sketch and driver internals were not fully sampled, so uncertain orchestration links are omitted or marked unverified.
Main entry points: cmdMode.cpp Serial command handling · mcp_can.h CAN driver API · Serial_CAN_Firmware.ino Firmware entry · EEPROM_SET.cpp EEPROM config helpers
Components 12
Serial-CAN firmware
- Firmware entry
Serial_CAN_Firmware/Serial_CAN_Firmware.ino - Serial command handling
Serial_CAN_Firmware/cmdMode.cpp - Firmware declarations
Serial_CAN_Firmware/func.h
Configuration storage
- EEPROM config helpers
Serial_CAN_Firmware/EEPROM_SET.cpp - Firmware constants
Serial_CAN_Firmware/firmware_dfs.h
CAN shield driver
- CAN driver API
libraries/CAN_BUS_Shield/mcp_can.h - MCP2515 CAN driver
libraries/CAN_BUS_Shield/mcp_can.cpp - MCP2515 definitions
libraries/CAN_BUS_Shield/mcp_can_dfs.h
Other components
- Serial host
- CAN bus
- Arduino EEPROM
- MCP2515 hardware
Connections 11
- Serial host → Serial command handling: sends commands
Serial_CAN_Firmware/cmdMode.cpp - Serial command handling → Serial host: returns replies
Serial_CAN_Firmware/cmdMode.cpp - Serial command handling → CAN driver API: configures and sends
Serial_CAN_Firmware/cmdMode.cpp - Serial command handling → CAN driver API: checks and reads
Serial_CAN_Firmware/cmdMode.cpp - Serial command handling → Arduino EEPROM: reads and writes
Serial_CAN_Firmware/cmdMode.cpp - EEPROM config helpers → Arduino EEPROM: reads and writes
Serial_CAN_Firmware/EEPROM_SET.cpp - Firmware entry → Serial command handling: dispatches
- Firmware entry → EEPROM config helpers: initializes
- CAN driver API → MCP2515 CAN driver: declares operations
libraries/CAN_BUS_Shield/mcp_can.h - MCP2515 CAN driver → MCP2515 hardware: controls over SPI
- CAN bus → MCP2515 hardware: carries CAN frames