Electronic – Interfacing with a truck’s internal CAN bus system

automotivecanpic

I'm currently exploring different ways by which I can communicate with a truck's internal CAN bus system and would like some advice on the most appropriate solution for me.

I have overviewed the CAN and J1939 protocols used in trucks. I would like to take CAN (J1939) messages from the truck and decode them into human readable data.

I'm thinking of connecting a Linux-based board to the system with a CAN transceiver and a CAN controller then make an application with Python and SocketCAN to decode the data. Can this work be done with a microcontroller only? Without having to use an OS-based system.

I know about the ELM327 for example. What is the difference between the frames that I would get from it and those that I would get directly from a CAN controller (MCP2515 for example) through SocketCAN?

Would programming a PIC microcontroller with the Microchip J1939 library be of any use to me here?

Best Answer

ELM327 is a factory-programmed PIC microcontroller that supports popular OBD2 protocols. It can also handle raw CAN but I would not count on it being a good CAN analyzer/sniffer or handle large amounts of data.

If your end goal is Linux and SocketCAN - I think it would be best if you just connected a MCP2515 HAT to a Raspberry Pi. You could then use the excellent Wireshark for analysis or write your own scripts. It is a popular and well supported configuration. Just google for countless tutorials.

If you go for a PIC MCU you will have to redevelop much of the drivers before you get into the SocketCAN subsystem.