gmenounos / kw1281test

VW KW1281 Protocol Test Tool
MIT License
111 stars 14 forks source link

Using cheap KKL adapter (ft232 clone based) on linux #71

Open ofauchon opened 2 months ago

ofauchon commented 2 months ago

Hi.

I have an old KKL adapter which I'd like to use with kw1281test:

image

I could test this adapter on Windows7/VAGCOM 3.xx or 4.xx (Connecting ECU, getting Identification, Fault codes) For that , I had to install the ftdi serial drivers and assigning a COM port to the interface and in VAG COM setup.

Note It's probably based on FT232 clone chipset (I guess it's a clone because it has empty iSerial ID value, and I can't read its eeprom)

Now, this is unclear how to use it on Linux with kw1281test (Yes, I read the Wiki doc first :-)

Should I install the "ftdi_sio" driver and use the corresponding tty device (eg: /dev/ttyUSB0) Or disable the "ftdi_sio" driver , and rely on the FTDI iSerial (which is "0" for my adapter)

Thanks for you for your help.

Olivier

gmenounos commented 2 months ago

I don't have a Linux environment to test, but I see the following in the Wiki:

"Only cables with an FTDI chip are supported on Linux. This is due to the fact that, in order to initiate communication with an ECU, we first need to send the ECU address at a low baud rate of 5 bps, then process its response at the selected baud rate. On Linux, we have not yet found a way to do this through the standard serial API, which is why we need to use a vendor-specific driver."

"(TODO prevent the kernel from loading the ftdi_sio module – as long as it is loaded, libftd2xx and thus kw1281test will not be able to access the interface.)"

So, sounds like you should definitely not use the ftdi_sio driver.

ofauchon commented 2 months ago

Hi,

For science, I still made some experiments with ftdi_sio and Linux.

$ dotnet run /dev/ttyUSB0 9600 1 ReadSoftwareVersion

Signal analysis showed two malformed "wake up" packets (with no ECU answer of course...)

image

I see two problems with these packets:

I guess there is something wrong/different in the way C# handles breaks/DTR lines on Linux.

I'll dig deeper in this UART implementation and perharps find a solution.

gmenounos commented 2 months ago

See this: https://github.com/gmenounos/kw1281test/issues/35

ofauchon commented 2 months ago

Hi,

I ended up writing a new "LinuxInterface" to have a full, low level control over the tty's control lines

Now I can connect my Golf 3 ECU with my KLL cable used (as a real UART device with ftdi_sio driver)

This new LinuxInterface uses "ioctl" to drive the tty device, so I 'm afraid it'll cause some portability issues.

I'll make more tests tomorrow, and then share the code through a Draft Pull Request. So We can discuss about this feature .

Thx

Olivier

$ ./bin/Debug/net8.0/kw1281test  /dev/ttyUSB0 2400 1 ReadSoftwareVersion 

Version 0.97.0-beta (https://github.com/gmenounos/kw1281test/releases)
Args: /dev/ttyUSB0 2400 1 ReadSoftwareVersion
OSVersion: Unix 6.7.8.1
.NET Version: 8.0.3
Culture: en-US
Opening serial port /dev/ttyUSB0
Sending wakeup message
Sent controller addr=$1  at 5baud
Reading sync byte
Keyword Lsb $01
Keyword Msb $8A
Protocol is KW 1281 (8N1)
ECU: 037906025R  SIMOS 4S           2104
Software Coding 00000, Workshop Code: 01317
Only supported for cluster
Sending EndCommunication block
gmenounos commented 2 months ago

Cool, thanks!

ofauchon commented 2 months ago

Some progress, but not yet working. (5 baud init is OK, ECU now answers, but interface can't receive the sync byte)

Here is my repo if someone interested ...

https://github.com/ofauchon/kw1281test/tree/linux-native-interface (Beware: WIP/Dirty code :-)

ofauchon commented 2 months ago

See PR #73 please .

Thanks Olivier

gmenounos commented 2 months ago

Sorry to not get to this yet. I've been out of town and am now back, catching up on things...