NefMoto

Technical => Communication Protocols => Topic started by: jrelder on March 05, 2017, 08:29:19 AM



Title: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jrelder on March 05, 2017, 08:29:19 AM
I am currently in the process of creating a display for my vehicle information. I am wondering what is the best way to extract this information from the CAN bus. I see two options:

1. Receive all CAN data on the line and then filter for the required values
or
2. Every x ms request the required values from the sensors on the CAN bus

Which would be the best method and why?

Thanks in advance!


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: seishuku on March 05, 2017, 09:23:31 AM
When I did my display for my old mk6 Jetta TDI, I just requested it the same way VCDS does it. You get exactly what you want, when you want it.
Besides that, you can't find soot load just floating around on the power train bus (not that I know of anyway), so I had to get that from the correct measuring block.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jrelder on March 05, 2017, 09:30:51 AM
Thanks, that's really helpful and that was the option I preferred.

I was trying to figure out exactly how others did it for a while now but I could only find explanations for people who had hacked OBD USB/Bluetooth devices. No explanation of how the data is retrieved at the CAN level.

One last question, I assumed you can only request one value at a time, hence if I need 4 sensor values I have to send 4 request messages?

The only issue with this if so, is that the values will update sequentially and not simultaneously, although I expect the time difference between each value update will be miniscule and the update period for each will be equal anyway.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: seishuku on March 06, 2017, 11:11:17 AM
That's how I ended up doing it in the end, one request for each item... It does slow down refresh a bit, but still real time enough for me.

In the VW TP2.0 protocol, there is a facility for assembling multiple request to batch it in one transaction, but I never had a chance to get it to work.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: nubcake on March 13, 2017, 05:09:29 PM
That's how I ended up doing it in the end, one request for each item... It does slow down refresh a bit, but still real time enough for me.

In the VW TP2.0 protocol, there is a facility for assembling multiple request to batch it in one transaction, but I never had a chance to get it to work.

You can define your own DDLI with all the values you need (there are some limits, though).
Tried it with MED9 - and without auth and any ECU patches - the F0 DDLI can contain up to 20 single-byte values. Or, to be precise, the last item can contain 20 sequential bytes as well.
So, up to 39 bytes without any additional tricks.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jameswalker on March 16, 2017, 06:16:58 AM
So, did you manage to successfully request anything? If so, do you know what messages do what? (even better, is there a document here on this site detailing it at all?)

I am currently doing similar, but by sniffing the bus directly.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: nubcake on March 16, 2017, 09:36:48 AM
So, did you manage to successfully request anything? If so, do you know what messages do what? (even better, is there a document here on this site detailing it at all?)

I am currently doing similar, but by sniffing the bus directly.

http://www.orlaus.dk/mercantec/UdvidetHardwareSoftware/Can/OBD2/VW%20Transport%20Protocol%202.0%20(TP%202.0)%20for%20CAN%20bus%20_%20jazdw.pdf
http://nefariousmotorsports.com/forum/index.php?topic=9182
Check Basano's and seishuku's posts.
There's enough info on here to build a working memory logger (or whatever you're trying to achieve) for the MED9, although it's a bit scattered.

EDIT: if you're talking about CAN packet contents - check FR.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jameswalker on March 17, 2017, 03:10:04 AM
Perfect thanks.

I located all the parameters I was after, there is still 1 which I cannot find. That is real time AFR (or, raw actual lambda value). Not user requested target lambda.

I am guessing, that it is not actually sent out over the CAN bus?? And that the only way to grab it is to request is? Could anyone clarify this?


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jrelder on May 23, 2017, 04:23:04 PM
So, did you manage to successfully request anything? If so, do you know what messages do what? (even better, is there a document here on this site detailing it at all?)

I am currently doing similar, but by sniffing the bus directly.

Hi,

Sorry for the late reply from myself. I actually didn't in the end as it turns out my car uses K-Line KW1281 instead of CAN to communicate, despite having a CAN bus. So I am now creating software for the K-Line. As for the values, I found everything I needed when I was looking at the CAN bus on the Wikipedia page for the OBD2 protocol. It tells you how to request values and which values are at which PID. It also tells you how to convert them into their meaningful decimal values.

Hope this might help you


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: golfdubcrazy on October 22, 2017, 06:53:26 AM
Hi

I know this is one of my first few posts but i have been doing this on and off for many years. my personal view is to connect direct to the engine CANbus (instead of going thru gateway) and just listen to the values on the bus, as most of the values you are looking will probably be transmitted.

in my view this reduces bus load on the canbus,gateway and ecu as it does not have to process what values you want before it can transmit. you should find reading directly off the bus will also give you a faster refresh rate.

Hope that helps


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 11, 2018, 10:59:11 AM
I'm in the process to make something similar. I want to go a bit further and create an inerface to mimic the hvac controls and some other buttons.
I have a 2004 Touareg which uses k-line. Engine ecu is a me7.1.1.
On what platform are you guys working?
I want to build a c# application and replace all the console with a touch screen.
Any help on k-line sniffing or bus sniffing is welcome.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: prj on March 11, 2018, 04:55:06 PM
First tip is ignore almost all the posts in this thread. Besides nubcake and seishuku it doesn't seem like anyone knows what they are on about.

You have two options.
You either connect to the CAN bus and passively sniff the data messages.
Look at ME7 FR in the "CAN" module, it contains all the messages the ECU sends including scaling and structure.

Or if you want some sort of data that is not in those messages, then you will have to set up a diagnostic session to the ECU like a scan tool does.
The Touareg has KWP2000 over K-Line. Nothing special there, simply fast init and then get the spec and just ask for things the same way you would do with VCDS.

You are going to have to compile a list of measuring groups and then a measuring block to data item mapping.
In KWP2000 you don't need to worry about scaling because each measuring block consists of 3 bytes - ID, A and B.
You can find most of the important formulas here to calculate the end result:
https://www.blafusel.de/obd/obd2_kw1281.html (https://www.blafusel.de/obd/obd2_kw1281.html)

I would advise against using DDLI or ReadMemoryByAddress because this is ECU specific. KWP2000 with fast baud and low comm timings is very fast anyway, you should not have refresh rate issues if you don't request more than 4-5 measuring groups, which is plenty.
You can improve the response by only requesting data that is currently on-screen for example.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 03:46:26 AM
Thanks for the info and the link. Interesting.
So if I understand you right it is doiable to sniff the messages sent by a button and mimic them in an app?
I don't have the car at hand all the time as it is stored far from home for the moment.
I thought about an odb emulator and a quick search returned this one:

https://freematics.com/pages/products/freematics-obd-emulator-mk2/

I need something to play to get started. Do you know or have used anything similar. or this is just a waste of money.
I have a 2009 Audi but the Audi uses CAN2 I think and the Touareg uses k-line so I cannot use the Audi for testing.

What is the ME7 FR in the "CAN" module ?

I Also found this blog which looks promising:

https://theksmith.com/software/hack-vehicle-bus-cheap-easy-part-1/
https://theksmith.com/software/hack-vehicle-bus-cheap-easy-part-2/





Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: jimmcgee5 on March 12, 2018, 04:11:18 AM
their is already a free app that works with a bluetooth dongle , https://github.com/theksmith/CarBusInterface/wiki


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 04:23:21 AM
Nice find there, thanks.
I will take a look and see how I can use the project to make my windows app.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 04:24:59 AM
So It looks like an ELM device is better suited for sniffing.
I thought about buying an FTR232RL cable to use for both nefmoto tools and for sniffing and making the app but I think the elm device is what I need for this project.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: prj on March 12, 2018, 05:01:32 AM
It's gonna be a hell of a lot easier for you if you are satisfied with the data that is already present on the bus on CAN.
Then you can simply listen to the CAN frames and pick out the relevant data without doing anything.

Communicating with the ECU and requesting is a lot more involved.

Not to mention it will block all other diagnostic communication attempts, if the hardware is permanently installed in the car.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 06:16:37 AM
So the elm device for sniffing and replicating the buttons and the ft232rl for diagnotics.
I can use the elm for reading measure block I guess.

The idea is to have an app which:
Show some info (read some measure blocks)
Replicate button/knob presses and => climate control buttons/knobs mainly as I will replace the headunit with a windows media player style frontend and I won't need the radio button messages.
The Touareg has special steering wheel with access to internal menus. if I can get the same functionnality as the buttons I will replace the steering wheel with a sportier/sexier wheel :-)


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: prj on March 12, 2018, 06:18:20 AM
Then you need some sort of uC devboard.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 06:21:56 AM
can you give some more details please?


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 06:23:06 AM
Touareg steering wheel


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 06:23:52 AM
I would like to replace it with something like this even without any buttons.



Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: prj on March 12, 2018, 06:28:35 AM
can you give some more details please?
If you need more details, then I don't have high hopes of you ever completing this.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 06:38:13 AM
 :)

There is always hope :-)


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: woj on March 12, 2018, 10:25:24 AM
ELM can do both CAN and K-line (but beware of the very cheap Chinese clones that have seriously castrated functionality), but you can't do them both at the same time. Also, it can sniff CAN traffic, but e.g. combining this with true diagnostics requests becomes cumbersome. Plus the serial AT protocol gives substantial overheads on communication and programming (I can make it work, it is versatile I agree, but I hate it with all my guts). For K-line a simple KKL based circuit will be sufficient, both for PC and a board of some sort, only needs suitable program coding. For CAN the best results I got so far was Arduino plus a CAN shield, you can actually buy integrated boards for this (see http://www.hobbytronics.co.uk/leonardo-canbus). But in either case, if you plan to do something interesting, you would have to solder a bit and decide and then design what you actually need. Also, proper MCP2515 programming on Arduino handling heavy and fast CAN traffic with multi frames is a PITA, you almost have to write a complete OS with interrupt based ring buffers and what not (I learned it the hard way couple of last months, with a finally perfect result). Another alternative is RaspberryPI with a CAN hat. Here the low level programming is sorted out by good people, yet there are other things to take care of (also went this route).

As an example, the picture (was supposed to, there is a problem with adding the attachment) is a box I made that hooks up to the CAN and to the Zeitronix Zt-2 module over serial at the same time, repackages it all into a new packet which is then sent over BT / another serial to my Android app. Plus it has a couple of ready equipped inputs and outputs for dash buttons and lights. Ideal would be to make a proper integrated board design and make it produced in small quantities, but that's just a proof of concept prototype. You can find a clip in a thread nearby.

So this is essentially the route you are on ;)


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: woj on March 12, 2018, 10:29:02 AM
Let's try the picture again...


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 10:56:56 AM
That's hope :-)
Thanks for the details.
What does your app do exactly?
Do you have a website or a blog/thread ?


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: woj on March 12, 2018, 11:02:32 AM
Oh dear, the laziness, three threads down man ;) https://www.youtube.com/watch?v=UJV2sLSf55s

No, no website / blog, had I have time for websites I wouldn't have time for doing these things...


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 11:19:14 AM
oh yes I see. I'm gonna take a look :-)
This is gonna be a hell of a project. I intend to keep the Touareg for some time so I will take my time to make the custom carpc with all the obd goodies :-)
So far I have a carpc with a media frontend (DriveLine) and a custom c# phone solution using a bluetooth dev board and a killer mike (https://partners.andreaelectronics.com/da-350-auto-array-microphone/)
BT Phone has always buggered me so I went the dedicated hardware route and bought a BT devboard and an array mike.
I will have to do some shopping for the Tesla-Style Touchscreen solution for the Touareg.

Here is a Tesla Style solution for the Passat. They don't make one for the Touareg.

http://www.suavdvdgps.com/a/Full_Touch_Android_GPS/VW_Series_andoid_GPS/2016/1027/1718.html






Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 12, 2018, 11:24:12 AM
https://www.youtube.com/watch?v=UJV2sLSf55s

Nice demo there !


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: woj on March 12, 2018, 02:46:51 PM
Are you sure you want to drive a tablet with four wheels? ;)


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: TRespect on March 13, 2018, 02:37:31 AM
I have been driving a windows PC with four wheels for a long time already :-)


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: tao13 on September 01, 2018, 08:12:13 AM
Hi all.
Today i tried to receive can message from my ecu on the bench , only power connected , no other sensor or instrument.
I used an arduino nano and a mcp2515 can shield
I connected pin 58 and 60 from ecu to mcp shield and i received only messges from the end of the post, repetly.
Maybe the pin 58 and 60 from ecu is only to send data to instrument cluster , but if it is like this what can pins arrived in OBD socket?
I'll tri to find an obd cable to cut and connect my mcp2515 shield directly on pin 6 and 14 on OBD and will see if receive something there or not.

Standard ID: 0x588       DLC: 3  Data: 0x08 0x00 0x7E
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0x0A 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x288       DLC: 8  Data: 0x0A 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0x0A 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0x56 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x480       DLC: 8  Data: 0x84 0x6C 0x00 0x00 0x00 0x00 0x00 0xE8
Standard ID: 0x288       DLC: 8  Data: 0x8F 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x488       DLC: 8  Data: 0x00 0x17 0x62 0x7E 0xA6 0x00 0x00 0x00
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x380       DLC: 8  Data: 0x80 0x80 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0xE8 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x488       DLC: 8  Data: 0x00 0x17 0x62 0x7E 0xA6 0x00 0x00 0x00
Standard ID: 0x288       DLC: 8  Data: 0x8F 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0x56 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x488       DLC: 8  Data: 0x00 0x17 0x62 0x7E 0xA6 0x00 0x00 0x00
Standard ID: 0x288       DLC: 8  Data: 0x0A 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x280       DLC: 8  Data: 0x11 0x61 0x00 0x00 0x17 0x00 0x17 0x17
Standard ID: 0x288       DLC: 8  Data: 0x56 0x5B 0x37 0x00 0x00 0x78 0x68 0x62
Standard ID: 0x288       DLC: 8  Data: 0x0A 0x5B 0x37 0x00 0x00 0x78 0x68 0x62




Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: macxxx on September 01, 2018, 03:15:48 PM
in OBD socket can pins are connected to the gateway or cluster ( eg.Passat B5 FL , A4 8E )

here you have some explanation of can frames ID: https://wiki.openstreetmap.org/wiki/VW-CAN#280_8_10.2F20.28Diesel.29ms_Motor_1


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: tao13 on September 03, 2018, 03:47:37 AM
Thanks for your answer.
I have a skoda octavia 1 , so i think i don't have a gateway.
If anybody have a copleate can id's list please attache it here.
many thanks in advance.


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: fukenbroken on September 03, 2018, 10:05:19 AM
read FR


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: airhaddock on November 07, 2018, 06:42:17 AM
What specific signals are you after?


Title: Re: CAN Vehicle Information Display - Should I sniff the CAN bus or request values?
Post by: tao13 on January 03, 2020, 03:58:25 AM
i try to send to ecu a request but without any response