Hacking Lexia Protocol for Arduino - I did it !

This is the Forum for all your Citroen Technical Questions, Problems or Advice.

Moderator: RichardW

Post Reply
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Hacking Lexia Protocol for Arduino - I did it !

Post by haydent »

Update, jump to this post for latest: http://www.frenchcarforum.co.uk/forum/v ... 74#p496777

old original post:

Code: Select all

Hi all, just going to post about my project and progress. Started from wanting the detailed data available via lexia for long term logging, without a pc. (also the native pc logging capability of lexia bombs out after a few minutes for me anyway.)

Bought a OBD2 logger, and it get the basics like fuel rail pressure, air flow & pressure, rpm, speed but wanted more.

Ideally to have a Arduino (embedded) micro controller running it so maybe you could have something like a turbo pressure gauge.

Decided it would probably be too hard to reverse engineer lexia's likely propriety diagnostic protocol, and instead focussed on getting an Arduino Due (with usb host support) to talk to the actia tool in the way lexia does on a pc.

Got a usb logger program, and logged the raw hex data being sent and recieved between lexia and the actia tool over usb.

Next after some time i got USBHOST mode to work on my arduino due, and actually got it talking with the actia tool !  :-D I could send the same hex data i captured and it would respond with hex data the same way it had when it was hooked up to the pc.

Next im the process of working out how to decode the data i want, eg turbo pressure reading from a bunch of hex which for me would be impossible, but im getting some tips by analysing an old version of lexia's files for clues...

Its funny to see that lexia appears to be a dos/windows 3.1 program, and citroen just kept putting it in wrappers to make it run in later versions of windows, and that lexia uses open source programs to do what it does like mozilla browser, eclipse ide, and firebird sql server ...
Last edited by haydent on 19 Jul 2016, 12:46, edited 3 times in total.
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino

Post by haydent »

Update: it seems all the functions i need to see to understand the usb protocol are locked up in lexia's dll's, so now im back to trying to crack the packet format 'manually':
http://stackoverflow.com/questions/2981 ... b-captures" onclick="window.open(this.href);return false;
Here you can see some captures and my attempt to work out the stucture of data transmission.
User avatar
Stickyfinger
(Donor 2016)
Posts: 10433
Joined: 28 Mar 2013, 21:05
Location: Somset my lovleee
My Cars: Xantia V6 ACTIVA 3ltr 24v Manual p1
Xm 2.1TD Ph2 Exclusive
AX, little Daffodil
SAXO White Mk1. Sally
x 1289
Contact:

Re: Hacking Lexia Protocol for Arduino

Post by Stickyfinger »

Hi Haydent

Interesting, but why ?
Alasdair
Activa, the Moose Rider
3x C5x7 Steering racks and counting
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino

Post by haydent »

For longer logging than lexia supports, and doing so automatically on engine start without need for computer, and for extended digital gauges beyond that which is accessible via obd2, protocol.
User avatar
Stickyfinger
(Donor 2016)
Posts: 10433
Joined: 28 Mar 2013, 21:05
Location: Somset my lovleee
My Cars: Xantia V6 ACTIVA 3ltr 24v Manual p1
Xm 2.1TD Ph2 Exclusive
AX, little Daffodil
SAXO White Mk1. Sally
x 1289
Contact:

Re: Hacking Lexia Protocol for Arduino

Post by Stickyfinger »

ahhh...OK thanks
Alasdair
Activa, the Moose Rider
3x C5x7 Steering racks and counting
User avatar
xantia_v6
Forum Admin Team
Posts: 9080
Joined: 09 Nov 2005, 22:03
Location: France or NewZealand
Lexia Available: Yes
My Cars: -
1997 Citroen Xantia V6 (France)
1999 Citroen XM V6 ES9 (France)
2011 Peugeot 308 CC THP 155 (NZ)
1975 Jaguar XJ-S pre-HE (NZ)
x 833

Re: Hacking Lexia Protocol for Arduino

Post by xantia_v6 »

The last hex digit in the protocol is fairly clearly a checksum, as if you add all the characters in a packet, mod 255, the sum is always F4 or F5 (I can't yet see why it varies by one). So it seems that the 8th character is the 8 bit ADC reading, which is converted to a % on the PC.

I have done a lot of protocol analysis in previous lives, and have written a few Wireshark dissectors, so this is an interesting problem for me, but I don't know how much time I can spend on it at present.
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino

Post by haydent »

xantia_v6 wrote:The last hex digit in the protocol is fairly clearly a checksum, as if you add all the characters in a packet, mod 255, the sum is always F4 or F5 (I can't yet see why it varies by one). So it seems that the 8th character is the 8 bit ADC reading, which is converted to a % on the PC.

I have done a lot of protocol analysis in previous lives, and have written a few Wireshark dissectors, so this is an interesting problem for me, but I don't know how much time I can spend on it at present.
yes i too was thinking there would likely be a checksum there at the end somewhere. there's no rush, glad to have your help and support. i thought it might be adc reading, and it likely is, but how do you think they are getting the 6 point precision float from it ? or the arnt instead creating it on the pc end by dividing 100% by a number of increments...
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino

Post by haydent »

Bringing this thread back from the dead, i abandoned trying to snoop and emulate the usb bus and instead focused on the other end of the diag tool, to diagnostics socket with great success ! it turns out to be quite simple to do, as the data im after is all available over the CAN bus at the standard 500kbps , you just have to watch how the actia tool does it and repeat. Ive done this and have made a data logger and display for the selected gear and gearbox electrovalve readings, but could easily be adapted to any reading available in lexia.
https://hackaday.io/project/12644-can-d ... can-shield
Image
jgra1
(Donor 2021)
Posts: 4625
Joined: 27 Nov 2005, 19:07
Location: Kent / Susssex
My Cars: 2010 C5 X7 2.0 hdi 160 exc auto
MG TF 135
Boxer II 2.2 camper conversion
BMW R1200RT
BMW K1300 R
Honda V F R 800 5thG / MT500 Armstrong
x 39

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by jgra1 »

Good work hayden. It doesnt mean a huge amount to me but i can the end result.
The nearest i get to a checksum is checking my bank balance!

Off topic all but i have an issue with my c5 and need to see the logs to help me understand what happens while driving.. can someone tell me where i need to be in diagbox to see log of car running..for example 2 days ago? I have done it before but by accident

Thanks
John
User avatar
GiveMeABreak
Forum Admin Team
Posts: 37300
Joined: 15 Sep 2015, 19:38
Location: West Wales
My Cars: C3 Aircross SUV HDi Flair Peperoncino Red (The Chili Hornet)
C5 X7 2.0 HDi Exclusive Mativoire Beige (The Golden Hornet)
C3 1.6 HDi Exclusive Aluminium Grey (The Silver Hornet)
C5 MK II 2.0 HDi Exclusive Obsidian Black
C5 MK I 2.0 HDi SX Wicked Red
Xantia S2 2.0 HDi SX Hermes Red
C15 Romahome White
XM 2.0 Turbo Prestige Emerald Green Pearlescent
XM 2.0 Turbo Prestige Polar White
XM 2.0 SX Polar White
CX 20 Polar White
GS 1220 Geranium Red
CX 2.4 Prestige C-Matic Nevada Beige
GS 1000 Cedreat Yellow
x 5711

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by GiveMeABreak »

You just need to go into the area you want to monitor - usually the specific ECU, then you should get a sub-menu, Measurements where you can select the particula tests to monitor - I think up to 10 specific measurements at the same time John.
Please Don't PM Me For Technical Help

Marc
jgra1
(Donor 2021)
Posts: 4625
Joined: 27 Nov 2005, 19:07
Location: Kent / Susssex
My Cars: 2010 C5 X7 2.0 hdi 160 exc auto
MG TF 135
Boxer II 2.2 camper conversion
BMW R1200RT
BMW K1300 R
Honda V F R 800 5thG / MT500 Armstrong
x 39

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by jgra1 »

Thanks.marc.. i think i meant a long text list of the cars life.. i saw one soon after i bought it which seemed to show the last mimutes of the engines failure.. a few months before.. ?

Ahh.. just did a quick google and it led me back to fcf and addo and a faults journal!! That is what i mean ;)

http://www.frenchcarforum.co.uk/forum/v ... hp?t=46645

Found it.. sorryyy ;)
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by haydent »

GiveMeABreak wrote:You just need to go into the area you want to monitor - usually the specific ECU, then you should get a sub-menu, Measurements where you can select the particula tests to monitor - I think up to 10 specific measurements at the same time John.
in lexia its only 6 custom parameters, and its pretty flaky at best, i also think it is only meant to record for 5 mins, but ive never gotten more than a couple before it drops with communication error.

my device automatically connects and reconnects if needed, so it can be left plugged in and will do its thing.
WastedSpark
Posts: 1
Joined: 29 Aug 2021, 03:18
Location: Australia
My Cars: 403, 404, 504, 505, 604, 406, RCZ, 3008, 5008

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by WastedSpark »

Hi Hayden,

I have a project that needs to read engine paramaters from the CAN bus. I'm using an Arduino Leonardo, MCP2515 and MCP2551 to communicate with the bus.

What I have found sofar is that the engine ECU broadcasts a number of parameters on the bus without prompting, however it is not as complete as the data available through the live-data feed in PP2000 using Lexia. Did you find that you need to transmit anything specific to the ECU to get the data that you need?

Thanks,
Scotty
haydent
Posts: 58
Joined: 22 Jul 2014, 10:55
Location: NSW, AU
My Cars: Citroen C5 II HDI
x 2

Re: Hacking Lexia Protocol for Arduino - I did it !

Post by haydent »

So yeah, you just monitor/record the can bus (with a y adapter) while requesting the data you want with pp tool, and then replicate that with your arduino tool. With my project i collected the required requests needed for the transmission, but you could do any system.
Post Reply