CAN Bus hacking: choose your weapons
Posted: 10 Apr 2019, 05:38
To do anything with CAN one needs to have some kind of physical interface. This can be done in many ways. I prefer using simple ones, accessible over virtual COM port drivers (VCP) using an easy to adpot, ASCII based protocol like SLCAN.
SLCAN is very easy to implenent by own software, because it has a basic challenge/respsonse design. You can read about it here: https://mk4-wiki.denkdose.de/artikel/can-bus/slcan
I wrote a small library in PHP to do the trivial tasks like connecting, sending and receiving messages. This is really low level and could be done "by hand" also, for debugging or small tasks. First, set CAN Bis speed with "S" command. For 125 kbit/s send "S4" followed by a CR (0x13) and it answer with a CR as OK or BEL (0x07) as ERROR.
After this you can open the channel by sending "C". Now you can send and receive messages. Both use the same format: "t" followed by three digit CAN ID in hex (padded with "0" if needed), next a one digit DLC and then all the bytes to send with message as two digit hex codes. For example, to send "02 11 81" to ID 720: "t7203021181". Easy, isn't it?!
SLCAN is very easy to implenent by own software, because it has a basic challenge/respsonse design. You can read about it here: https://mk4-wiki.denkdose.de/artikel/can-bus/slcan
I wrote a small library in PHP to do the trivial tasks like connecting, sending and receiving messages. This is really low level and could be done "by hand" also, for debugging or small tasks. First, set CAN Bis speed with "S" command. For 125 kbit/s send "S4" followed by a CR (0x13) and it answer with a CR as OK or BEL (0x07) as ERROR.
After this you can open the channel by sending "C". Now you can send and receive messages. Both use the same format: "t" followed by three digit CAN ID in hex (padded with "0" if needed), next a one digit DLC and then all the bytes to send with message as two digit hex codes. For example, to send "02 11 81" to ID 720: "t7203021181". Easy, isn't it?!