CANbeSerial
Feb 11, 2024
The CANbeSerial protocol was designed to allow the transportation of CAN-Bus frames on any serial stream interface. Possible interfaces include, but are not limited to, Serial Port (RS-232), TCP, and UDP.
CANbeSerial implements its own framing (COBS) and error-checking (CRC16) mechanism and is therefore independent of any mechanisms of an underlying protocol. This allows for fully transparent conversion between different types of interfaces. For example, it would be possible to convert a CANbeSerial datastream from TCP to RS232 and subsequently CAN-Bus without any repackaging or logic in the TCP to RS232 conversion step.
Prior Art
The concept of converting CAN messages to a serial data format is nothing new. Here are some prior attempts at doing so:
Commercial and proprietary solutions
There are many commercial something-to-CAN converters. Some of them are bad but some are really good. If you are looking for a good USB-to-CAN converter I can highly recommend the PCAN adapters from Peak-Systems.
I will not attempt a comparison between any commercial product and CANbeSerial.
candleLight
candleLight is another protocol that I have seen implemented in multiple devices.
Unfortunately, I was not able to find a document of the protocol but it seems to be USB only.
SLCAN
SLCAN is an ASCII-based serial protocol developed by LAWICEL. It seems to be very well supported in a multitude of open-source software but is also very limited.
Benefits of CANbeSerial over SLCAN
- As with many ASCII-based protocols, SLCAN nighter implements a robust framing mechanism nor does it have any error check for the serial data.
- Not having to encode/decode strings removes complexity and makes implementations on microcontrollers easier and more robust.
- CAN-FD support.
- Received CAN messages are forwarded directly. Polling of the receive buffer is not required.
- Extensive acknowledgment, status, and error messaging from the device.
Supported Hardware
CANbeSerial has been implemented on a Makerbase CANable V2.0 Pro. Documentation of the hardware including a schematic can be found on the Makerbase CANable GitHub page.
If you would like to purchase this product you can do so using the following Aliexpress affiliate-link. Please note that except for this link, there is no affiliation between me and Aliexpress or Makerbase.
Firmware Update
To upload the firmware to the device, it needs to be booted into the DFU bootloader first.
To do so, open the device and bridge the pin header labeled "boot".
To open the enclosure you need to pull apart the top and bottom half. The parts are neither glued nor screwed together.
After bridging the boot header, plug the USB connector into your computer and the device should enter the DFU bootloader.
There is already a lot of information on the internet describing how to update firmware using the ST DFU bootloader. Therefore I will not explain it here. The search term to use is "ST DFU".
After the firmware upload is completed, unplug the device and remove the bridge from the "boot" pin header.
Hardware modifications (optional)
The three LEDs on the device had significantly different levels of brightness. The blue LED was very bright while the green LED was nearly visible. To fix this, I replaced the resistor for the blue and green LED.
Please note that this modification is not necessary to get the CANbeSerial firmware running on the device and is purely cosmetic.
However, if you too are bothered by this you can replace the resistors marked in the picture below with the following values:
- Red: leave as is (1k ohm)
- Green: 470 Ohm
- Blue: 10k Ohm