Software On ELM Street - OBD2 Software Development

Programs / Tools / Scripts
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

hhaha, got it!
Sending 03AA01F9 requests the dpid once.

We now have enhanced DPID support for CAN11bit. :thumbup:
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

Multiline read and writing... check :D

Back to hammering into the tech2..
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
antus
Site Admin
Posts: 10016
Joined: Sat Feb 28, 2009 10:34 am
cars: TX Gemini 2L Twincam 8psi
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Subaru WRX 2007

Re: ELM327 Software Development

Post by antus »

Nice work :)
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
delcowizzid
Posts: 5709
Joined: Sat Feb 28, 2009 10:38 am
Yahoo Messenger: [email protected]
Location: Wellington NZ

Re: ELM327 Software Development

Post by delcowizzid »

omg those gauges pure awesome
If Its Got Gas Or Ass Count Me In.if it cant be fixed with a hammer you have an electrical problem
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

delcowizzid wrote:omg those gauges pure awesome
Cheers mate, still a couple more to add in.

Jayme, just a heads up, you will need to use 04 in the dpid "fire off" message.. since using 01 does work.. but you can only request 1 frame every secondish soo its extremely slow. using the 04 will make that dpid spam off onto the bus, which is not 100% ideal for the elm but should be sweet on the AVT cable. :thumbup:

Sooo.. to deal with the dpid spam onto the bus and capturing with the elm.. I think I have found a way around manually requesting each frame, and be able to read each message from the bus. Since the ecu likes to get "tester present" messages which keeps the data flowing.. I think if I set the "receive" header to 5DF and then request a 7E0 01 3E.. I should pick up the dpid message.. I think! So I kill two birds with 1 stone!

I also thought of a new delema... when adding in new controls, I add them into a control container for future reference, But I will need to be able to redo the DPID setup so new frames are sent containing the desired PID.
GM documentation explains this is simply done by the normal procedure, even when the previous DPID is being sent off still, and will update that DPID on the bus after the "successful" dpid setup message has occured. Its said it is good practice to skip the next couple of frames to ensure the dpid has been updated.

So with ever change DPID's. I will need a predefined list of the amount of bytes each PID requires in a PID, I then need to record where each PID will occur in the DPID frame.... where finally once the frame has been received.. some simple coding as below to get the work done:

Code: Select all

Dim ActiveCustomControls() as controls 'collection of all the custom controls to modify
Dim PIDsActive() as SupportedPIDs  'Array of all active PIDs
Dim dpidFEpids() as PIDssetup 'Array of all pids in DPID FE,locations and size

Dim FoundMessage as string = GetECUResponse(SentMessage,SerialPort,ErrorReport) 'get response, handle errors, pass on serialport to prevent crossthreads.
Dim SpitFoundMessage() as string = FoundMessage.Split(" ") '5E8 FE 00 00 6E 00 00 00 00

try
Select Case SplitFoundMessage(1) 
   Case "FE"
        HandleDPIDFrame(SplitFoundMessage,dpidFEpids,PIDsActive,ActiveCustomsControls) 'check controls for active pids in dpid, update controls.
   Case "FD" 'ect continues on   

End Select
catch ex as exception
'error reporting here...
End try
If anyone has a better idea on how to manage multiple controls and ever change dpid setups.. please let me know! As its gonna be a looooonnnng day getting this to work.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

Have to figure out how many bytes each pid sends back..otherwise we wont know what to grab!.. Hmm.. will have to start making a definition file and go back to reversing the tech2 to sort this out.

At least we have some simple ones:
Engine RPM 000C = 2bytes
Vehicle Speed 000D = 1byte
Manifold pressure 000B = 1byte
Engine Coolant Temp 0005 = 1byte
Engine Mass Airflow 0004 = 2bytes
Spark Advance 000E = 1byte

Example frame:
7E0 10 0C 2C F7 00 0C 00 0D
7E0 21 00 0B 00 05 00 04

Would then get back:
5DF F7 XX XX YY ZZ PP DD DD

which makes up our first DPID.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Jayme
Posts: 2585
Joined: Sat Feb 28, 2009 10:59 pm
Location: North Coast, NSW

Re: ELM327 Software Development

Post by Jayme »

hmmmm ill have to figure out how to do that filter for my avt... so far ive only figured out how to set the filter mask to exclude all packets except for 7Ex. if the DPID response is 5DF, I hope I can set two filters...
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

Jayme wrote:hmmmm ill have to figure out how to do that filter for my avt... so far ive only figured out how to set the filter mask to exclude all packets except for 7Ex. if the DPID response is 5DF, I hope I can set two filters...
You should have an idea of what the ecu will respond with for which requests. So during setup, set the filter mask to 7EX as you have. Then once you have sent of the final message to spam all DPIDs.. just change the filter to 5DF (or 5DX is you dont care about the last byte)

Once all logging is done, clear all filters.

To prevent any mismatch with the ELM. The first things that occur on every command is to clear all filters and reset the header. Since different parts of the app will require different headers or filters as seen with this engine info.


Alternatively, since the AVT displays all chatter, you can turn off all the filters on the AVT and filter the info via program?

And add a simple inprogram timer to send off the tester present... something like this:

Code: Select all

 testerCurrentmillis = DateTime.Now.Ticks 'current time application has run
                    deltaMillis = (testerCurrentmillis - Testerinitialmillis) / TimeSpan.TicksPerMillisecond 'time in millis from last tester present sent
                    If deltaMillis >= 2000 Then 'if greater than 2000, send tester present message
                        Testerinitialmillis = DateTime.Now.Ticks 'reset last tester present time to now
                       SerialPort1.WriteLine(TesterPresentFrame)
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3626
Joined: Thu May 17, 2012 10:53 am
cars: VE SS Ute
Location: WA

Re: ELM327 Software Development

Post by Tazzi »

900 lines of code later.. and the CAN DPID implementation is almost finished. :thumbup:

When adding a new user control, the process is:
-Add new user control into control container array
-Set "HaveControlsChanged" property to true
-On next Engine Read, application will see "Have controls changed" = true and will get all Active controls
-From each control, each PID is extracted for each control (duplicate PIDS removed)
-Each PID is then allocated to a DPID, size and location of each PID is recorded. Max size of 7 bytes in a DPID response, up to 7PIDS.
-All used DPIDs are then added to the "spam off" frame and sent
-Start gathering engine data
-Sort each response to respective DPID subroutine
-In each subroutine, obtain data based on PID size and location
-Finally update all controls based on the PID name (if multiple controls have RPM, then all will be updated with same value)

The same process occurs when deleting a gauge ect. :thumbup:


I know having predetermined DPID values would be easier, or letting the user set this info from the beginning.. but wheres the challenge in that :lol:
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
antus
Site Admin
Posts: 10016
Joined: Sat Feb 28, 2009 10:34 am
cars: TX Gemini 2L Twincam 8psi
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Subaru WRX 2007

Re: ELM327 Software Development

Post by antus »

Jayme: yes you can on the AVT
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396