Electronic – Sending CAN protocol data(1Mbps) via serial port

cansoftware

I would like to build a tool for viewing CAN protocol data on my computer. The CAN protocol data is captured using a microcontroller (STM32F4 discovery board) and sent to a PC via a serial port. My requirement is to send only CAN ID, DLC, DATA and time stamp (i.e at what time a particular CAN ID was received).

I have a few questions that I couldn't find good results for after searching the Internet:

  1. Is it possible to send CAN data via the serial port using some compression techniques for the data packets since the CAN protocol operates at 1Mbps and I am planning to run the serial port at 115200 baud rate? If yes, could you provide information or links?

  2. Have you seen any similar projects which send 1Mbps CAN data via serial port. If yes, could you provide information or links?

Best Answer

I suppose that your CAN devices won't be sending data all the time. Implement a buffer (e.g. a circular buffer) and fill it while you receive data, then send out the data via your serial port. Once the buffer overflows, make sure you signal that to the host as well.

Compression only makes sense when you know your data. If the data is random, you could use e.g. RLE, which is a quite simple type of encoding and doesn't require much calculation power.

But as I said before, I don't think you will need that.