elm327 + can-bus

  • Anonymous - 2011-08-07


    I've downloaded the CVS-Version from freediag (08.07.2011 19:30) to use CAN-Bus. After unpacking and ./configure -enable-rcfile, i want to make, BUT got an error:

    edge freediag # make
    make  all-recursive
    make: Entering directory `/home/alex/Downloads/freediag'
    Making all in scantool
    make: Entering directory `/home/alex/Downloads/freediag/scantool'
    make  all-am
    make: Entering directory `/home/alex/Downloads/freediag/scantool'
    gcc -DHAVE_CONFIG_H -I. -I..  -I../include   -g -O2 -MT diag_l0_elm.o -MD -MP -MF .deps/diag_l0_elm.Tpo -c -o diag_l0_elm.o diag_l0_elm.c
    diag_l0_elm.c: In function ‘diag_l0_elm_sendcmd’:
    diag_l0_elm.c:138:3: warning: field precision should have type ‘int’, but argument 5 has type ‘size_t’
    diag_l0_elm.c:143:3: warning: field precision should have type ‘int’, but argument 5 has type ‘size_t’
    diag_l0_elm.c:171:3: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
    diag_l0_elm.c: In function ‘diag_l0_elm_initbus’:
    diag_l0_elm.c:396:2: error: ‘global_state’ undeclared (first use in this function)
    diag_l0_elm.c:396:2: note: each undeclared identifier is reported only once for each function it appears in
    diag_l0_elm.c:396:17: error: ‘STATE_CONNECTED’ undeclared (first use in this function)
    diag_l0_elm.c: In function ‘diag_l0_elm_send’:
    diag_l0_elm.c:437:3: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
    diag_l0_elm.c:452:3: warning: format ‘%s’ expects type ‘char *’, but argument 5 has type ‘char (*)’
    diag_l0_elm.c: In function ‘diag_l0_elm_recv’:
    diag_l0_elm.c:533:3: warning: format ‘%02x’ expects type ‘unsigned int *’, but argument 3 has type ‘char *’
    make: ***  Error 1
    make: Leaving directory `/home/alex/Downloads/freediag/scantool'
    make: ***  Error 2
    make: Leaving directory `/home/alex/Downloads/freediag/scantool'
    make: ***  Error 1
    make: Leaving directory `/home/alex/Downloads/freediag'
    make: ***  Error 2

    System is: gentoo-sources-2.6.39-r3 / gcc-4.5.3

    Any ideas?

  • CSB

    CSB - 2011-08-07

    yeah I forgot to comment a line in the code yesterday before committing… I just fixed it so you can "cvs update" and retry. The other warnings you see should not cause problems.

  • CSB

    CSB - 2011-08-07

    By the way, as I mentioned in another post, CAN-bus is not supported, unless you use l2protocol=RAW with an ELM327 and send the commands manually.

  • Anonymous - 2011-08-08

    Okay, now i can compile and install. After setting up the parameters i've scan.

    This returned.


    CAN-Bus isn't supported yet? Hm okay, but you have can in ./scantool/l2config. Is it possible for you, to add CAN-Bus support? Or is it too difficult?

    Which commands? Do you have any suggestions?

    Thanks for supporting man. :)

  • CSB

    CSB - 2011-08-08

    Yes, the old dev team had started adding CAN support but it's a huge unfinished job that I'm not willing to tackle any time soon… I'm focusing on proper ELM support first. But since the ELM327 supports CAN, if you send the right commands you might have some success, although you could very well do the same thing with any terminal software. Read the datasheet on http://elmelectronics.com/obdic.html#ELM327 for more information.

    The last log you've pasted indicate that you're having trouble just communicating with your ELM. Does it work if you use minicom or any simple terminal software to speak to the ELM ? i.e. send an ATZ command and receive a correct prompt, etc.

    Also : at the moment, I can almost guarantee that the "scan" command won't work with ELM… Read the top post at https://sourceforge.net/news/?group_id=34714 .

  • Anonymous - 2011-08-10


    i will help you to make can-bus connections possible. i can test everything ;)

    as you mentioned, i've test the ttyUSB3 device with a serial-connector like minicom. but i've some troubles with configuring it. it's a little bit confusing me. :-/ Here is my minirc.dfl. Can you find some troubles? After exit the setup-menu the modem initialized and shows no error. Below in the statusbar it masked "OFFLINE". What should i do now? When i was typing "AT" nothing happend… After killing minicom, the logfile doesn't show me any useful messages, just "Hang up…"

    Do you have any suggestions?

  • CSB

    CSB - 2011-08-10

    You need to configure a few things in minicom first (ctrl+a ; P   and ctrl+a; O)
    -baud rate to 9600
    -hardware & software handshake OFF

    then try sending ATZ.  If you get no answer try 38400bps… you should at least see blinking lights on your ELM.

  • Anonymous - 2011-08-10

    Ok i've set this, but where i should send ATZ? Just within the minicom just typing? i don't see what i'm typing. below in statusbar OFFLINE. i think i'm not connected with the /dev/ttyUSB3


  • CSB

    CSB - 2011-08-10

    Yes you just type in the commands. By default what you type isn't shown. minicom is made to work with real modems, so never mind what it says about the status. You did set the device though ? (minicom -D/dev/ttyUSB3 for example)

  • Anonymous - 2011-08-10

    Yes, it is shown up in minicom "Port /dev/ttyUSB3" but everthing i type, nothing respond. Always offline below.

    The elm327 is plugged in usbport, module ftdi_sio is automatically loaded, device is handled. Must the device plugged in OBD2 for testing? I don't think so, isn't it?


    Bus 006 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC


    Module                  Size  Used by
    ftdi_sio               29830  1

    ls -l /dev/ttyUSB3

    crw-rw---- 1 root uucp 188, 3 Aug 10 18:14 /dev/ttyUSB3
  • CSB

    CSB - 2011-08-10

    Hahah sorry, I just remembered, yes you have to have something plugged on the OBD2 side because the ELM chip is powered from your car's battery. It took me a while to figure out that one last week… If you have an IRC client I'll be monitoring #freediag on irc.freenode.net a few times today.

  • Anonymous - 2011-08-10

    Omg omg… :D I'll test it tomorrow, because the germany football team is playing against brasil. ;) See you tomorrow, thanks for supporting! *thumbs up* I'll install some irc client to contact you. ;)

  • Anonymous - 2011-08-11

    Back again with some first successfully tests. With plugged ELM327 to OBD2 and USB i can communicate a little bit with it.


    # Machine-generated file - use "minicom -s" to change parameters.
    pu port             /dev/ttyUSB3
    pu baudrate         38400
    pu minit            ATZ
    pu mreset           D
    pu rtscts           No
    pu macenab          No
    pu logfname         /var/log/minicom.log
    pu localecho        Yes

    If i send ATZ to the device i get an answer "LM327 1.4a". Any other commands will reply "0 DATA", but the ELM327-device is blinking… i think i've to choose some more parameters, or!?

    With scantool and l1/l2protocol raw, i get these messages

    Kind regards

  • CSB

    CSB - 2011-08-11

    glad to hear you got at least some success. So it turns out your ELM327 uses 38400bps as its speed… I was afraid some devices would use that, but 9600bps was hardcoded in freediag. I'll have to fix this, but in the meantime you can just modify diag_l0_elm.c to force 38400bps. I think modifying line #249 should do the trick…


Log in to post a comment.