Comer352L / FreeSSM

GNU General Public License v3.0
214 stars 67 forks source link

Tactrix OpenPort 2.0 support #23

Closed whitelynx closed 6 years ago

whitelynx commented 6 years ago

The documentation says that the OpenPort 2.0 is not supported currently. What would be needed in order to add support for it? Shouldn't the J2534 code support it?

I have an OpenPort 2.0 that I'd be willing to test with, and I could probably help with development if I had some idea where to start.

Comer352L commented 6 years ago

The OpenPort 2.0 interface claims to be J2534-compliant, so it should work indeed. Make sure you have installed the latest interface drivers (J2534 library). The interface should then be found by FreeSSM and show up in the preferences. If it doesn't show up or communication fails: Compile the sources as "debug", start the software from the terminal and send me the debug output.

whitelynx commented 6 years ago

OK, I installed https://github.com/NikolaKozina/j2534 (I hope that's the correct driver) using sudo make install and then re-built FreeSSM:

make clean
qmake-qt5
make debug

and ran the generated FreeSSM from the current directory (didn't bother installing it) and it does show SAE J2534 Pass-Through in the Interface-Type options, but the Interface-Name drop-down is empty and disabled, and the Test Diagnostic Interface button is disabled.

Here's the debug output:

qt5ct: using qt5ct plugin
libpng warning: iCCP: too many profiles
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

Also, for reference, this is what happens in dmesg when I plug in the OpenPort 2.0:

kern  :info  : [Wed Mar 21 10:41:52 2018] usb 1-2: new full-speed USB device number 11 using xhci_hcd
kern  :info  : [Wed Mar 21 10:41:52 2018] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
Comer352L commented 6 years ago

Ahh, you are trying to uses this interface on Unix ? Interesting ! AFAIK Tactrix only provides a J2534-library for Windows and I wasn't aware of any 3rd party J2534 library. Let's find out if it works...

On non-Windows systems (only), an additional configuration file is used: "definitions/J2534libs.xml". If you didn't install the J2534-library to the FreeSSM working directory, you have to edit the library path in this file. The rest is already suitable for the OpenPort 2.0. As soon the path is correct, the interface will show up in the preferences.

Comer352L commented 6 years ago

Looks like NikolaKozinas library accesses the interface using "libusb". Most Distros install this library by default these days.

whitelynx commented 6 years ago

Yes, sorry, I should have probably specified that... I'm running Manjaro Linux (kernel 4.9.87) and I definitely have libusb installed. (/usr/lib/libusb-0.1.so.4.4.4)

I'll try editing the XML file and see if that fixes it.

whitelynx commented 6 years ago

Also, in the future it might make sense to detect the install path of libj2534.so using pkgconfig, since https://github.com/NikolaKozina/j2534 installs with a j2534.pc file. If this fixes things, I might work on that later.

whitelynx commented 6 years ago

OK, I ended up just copying libj2534.so into the FreeSSM directory, and running the app from there. That complained about permissions on the USB device, so rather than fight with udev rules right now, I just ran it with sudo. This worked to get it to the point of showing libj2534.so as the Interface-Name.

However, when I tried clicking Test Diagnostic Interface, it brought up the Testing interface... Please wait! dialog, and then just sat there forever. There was no way to cancel or close the app aside from Ctrl+C on the command line or killing it.

Here's the debug output:

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
libpng warning: iCCP: too many profiles
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

Interface information:
   Firmware version: 1.12.3688
   DLL version:      2.0.1
   API version:      04.04
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

SSMP2communication::run():   operation: readMulti
SSMP2communication_core::SndRcvMessage(...):   sending message:
   80 10 F0 05 A8 00 00 00 61 8E
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x2, extra data index 0:
=> message indicates that an incoming message transfer has commenced.
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x1, extra data index 10:
80 10 F0 05 A8 00 00 00 61 8E
=> message is loopback message
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x2, extra data index 0:
=> message indicates that an incoming message transfer has commenced.
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA

It got to that point within seconds of hitting the Test Diagnostic Interface button, and then didn't produce any more output until I killed the app. (I tried it twice for good measure, after unplugging the OpenPort and plugging it back in)

Comer352L commented 6 years ago

Looks good so far. Interface sends the test message, a valid reply from the ECU is received.

The infinite blocking seems to be a bug in the J2534 library: PassThruReadMsgs() doesn't handle timeout=0 correctly. As a workaround for testing, you can change the timeout value in line 520 of J2534DiagInterface.cpp from 0 to 1.

Comer352L commented 6 years ago

Using pkg-config doesn't make things easier. J2534 libraries are device specific. So each interface uses it's own library. Hence, even the library names differ.

For Windows, SAE-J2534 specifies registry keys, which are used to register and find all J2534-libraries. Unfortunately, the spec creators didn't care about any other OS (yet ?). :(

whitelynx commented 6 years ago

For Windows, SAE-J2534 specifies registry keys, which are used to register and find all J2534-libraries. Unfortunately, the spec creators didn't care about any other OS (yet ?). :(

Sounds like ODBC. ;)


I tried changing the timeout value to 1, and now the log looks like this:

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
libpng warning: iCCP: too many profiles
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

Interface information:
   Firmware version: 1.12.3688
   DLL version:      2.0.1
   API version:      04.04
Trying to load J2534 library definitions XML file: "./definitions/J2534libs.xml"
Parsing J2534 library definitions XML data...
Found 1 registered J2534-libraries:

  Name:        libj2534.so
  Path:        ./libj2534.so
  API-version: 04.04
  Protocols:   ISO14230 ISO15765 ISO9141

SSMP2communication::run():   operation: readMulti
SSMP2communication_core::SndRcvMessage(...):   sending message:
   80 10 F0 05 A8 00 00 00 61 8E
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x2, extra data index 0:
=> message indicates that an incoming message transfer has commenced.
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x1, extra data index 10:
80 10 F0 05 A8 00 00 00 61 8E
=> message is loopback message
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x2, extra data index 0:
=> message indicates that an incoming message transfer has commenced.
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
PassThruReadMsgs(): received J2534-message with protocol id 0x3, rx status 0x0, extra data index 7:
80 F0 10 02 E8 40 AA
<snip>

It repeats those last lines constantly until I kill the app.

Also, if I try skipping the test and instead attempt to open any of the Control Units on the main window of the app, it gives me the error Couldn't open the diagnostic interface! Maybe the device is already in use by another application. and displays just the following line in the terminal:

PassThruOpen() failed: 

Should I open a bug on https://github.com/NikolaKozina/j2534 ?

Comer352L commented 6 years ago

Looks like another bug in the library. The ECU always sends 1 reply only, but PassThruReadMsgs() returns the last received message again and again... The PassThruOpen() error is very likely caused by killing the app, so nothing to worry about.

Comer352L commented 6 years ago

Looking deeper into the code, there seem to be more issues... Time to create a bug report.

Comer352L commented 6 years ago

Done: https://github.com/NikolaKozina/j2534/issues/3

whitelynx commented 6 years ago

Thanks!

NikolaKozina commented 6 years ago

I wrote my driver to support RomRaider (and my standalone OpenGL logger) logging under Linux. Patches are always welcome though. I don't have my Subaru with me to test at the moment.

Comer352L commented 6 years ago

I wrote my driver to support RomRaider (and my standalone OpenGL logger) logging under Linux. Patches are always welcome though. I don't have my Subaru with me to test at the moment.

Well, AFAICS the 2nd issue is relevant for RomRaider, too.

Anyway, of course we can't force you to fix it. I really appreciate your efforts to create such a library. So thank you so far, it's at least a good starting point.

Comer352L commented 6 years ago

David, thank you testing ! From the applications point of view, there is really nothing we can do, sorry. Someone needs to fix/improve the library.

kevin230 commented 4 years ago

Hey. Does the openport 2.0 works for Windows or not ? Thank you