linux-can / can-utils

Linux-CAN / SocketCAN user space applications
2.42k stars 714 forks source link

Is it possible to use TCP/IP socket from ELM327 clones? #287

Open maxdd opened 3 years ago

maxdd commented 3 years ago

Hi, as per the title would it be possible to use the ELM327 clones together with these tools? As far as i can see the ELM327 is providing a WIFI network and via Telnet to port 35000 it is possible to send AT commands as well as OBD PIDs request (maybe less relevant)

https://www.sparkfun.com/datasheets/Widgets/ELM327_AT_Commands.pdf https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide/obd-commands

as far as i can see using the following guide it should be possible to sniff the CAN

https://www.csmagics.com/single-post/2013/07/24/this-is-the-title-of-your-first-image-post

Regards,

hartkopp commented 3 years ago

Here is a project that implements the ELM327 raw protocol and make it a SocketCAN compatible device: https://github.com/norly/elmcan To interconnect this driver with WIFI you would need some 'netcat' script that redirects the traffic to a tty or pty, so that the above driver can access the content.

Alternatively you might build some program which talks to the ELM327 over WIFI and route the CAN frames to a virtual CAN interface in which you can use the can-utils then.

Something similar to this https://github.com/linux-can/can-utils/blob/master/slcanpty.c

Regards, Oliver

maxdd commented 3 years ago

So as far as i understood i should compile the elmcan and use something along this

sudo socat pty,link=/dev/ttyCAN0,raw tcp:192.168.0.10:35000&

and then

sudo ldattach \
       --debug \
       --speed 38400 \
       --eightbits \
       --noparity \
       --onestopbit \
       --iflag -ICRNL,INLCR,-IXOFF \
       29 \
       /dev/ttyCAN0

at this point in a terminal what shall i type?

./cansniffer any

or looking at the code (i'm no expert)

./cansniffer elmcan

is it ok?

leao-nardo commented 3 years ago

@maxdd hows it going ? did you tested it ? did it worked ?

yegorich commented 3 years ago

If ELM327 firmware can understand SLCAN protocol, you could use the same commands as we do for our NetCAN Plus devices:

  1. sudo sh -c ”socat pty,link=/dev/netcan0,raw tcp:192.168.1.5:2001 &”
  2. slcand -c -o -s8 /dev/netcan0 - this command creates slcan0 CAN device
  3. ip link set up slcan0

Now you can use slcan0 device with candump, cansend etc. like you would do with can0 device.

For more details, see our manual