Reading ALDL frames in VB

Post Reply
megajuz3003
Posts: 74
Joined: Sun Aug 26, 2012 9:47 pm
cars: 2001 VU SS
Location: Brisbane

Reading ALDL frames in VB

Post by megajuz3003 »

I'm playing around with reading data from my car with VB, primarily because I want more experience with programming fundamentals but I cant seem to get it right

I've tried various loops (while, do, try, for) with ReadByte after sending a request, and I get the frame back but its always out of order

essentially my code works by sending the frame then...

' n Chars of Bus into Buffer
Dim x As Integer = 0
Dim BufLen As Integer = ArrayBuffer.Length - 1

While x <= ArrayBuffer.Length - 1
ArrayBuffer(x) = SerialPort1.ReadByte
x = x + 1
End While

this reads 200 bytes from the data bus then passes it over to another loop to find the response...

I was wondering if anyone could point me in the right direction
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Reading ALDL frames in VB

Post by antus »

This is totally the wrong approch. You need to process the data like a stream. This will be very slow and accessing an array like that (eg incrementing x and the using it to write to an offset directly) is very not clean.

I'd recommend reading 2 bytes. Store the first as the device ID, the next as the length. Do the maths on the length then read the rest of the packet. This will work provided you dont get out of sync with the bus. Once you have this working look in to setting up a handler that can detect nonsense and reset and re-try to sync up. If you can handle it setting up a reader thread and processing data when you receive and event is more the correct approach.

Also, if you dont need to use VB, you might find something like C# is easier to use for this type of stuff, but ultimately thats your call. VB does not handle raw data particularly well though you can force it to 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
Majinsoftware
Posts: 8
Joined: Wed Aug 28, 2013 4:33 pm
cars: delco

Re: Reading ALDL frames in VB

Post by Majinsoftware »

Did anything ever come of this.
Im writing plugins in C# for dyno software to support ALDL logging sensor data straight into dyno overlay. Any code any one can share will save me some time.
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Reading ALDL frames in VB

Post by antus »

Have a read of this viewtopic.php?f=10&t=219&p=2055#p2055
You'll need to get an adx for each car you want to support and save the offsets in the data returned for the pids your logging (though no actual pids in aldl) and the equasions.
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
Majinsoftware
Posts: 8
Joined: Wed Aug 28, 2013 4:33 pm
cars: delco

Re: Reading ALDL frames in VB

Post by Majinsoftware »

Thanks, I had already had a read of that and got all the info I need. Was just hoping there was some .net code I could easily use to save time since iv got 4 datalogging protocols support so far out of a request list of 11 lol.
pman92
Posts: 464
Joined: Thu May 03, 2012 10:50 pm
cars: HZ One Tonner
VE Ute
Location: Castlemaine, Vic

Re: Reading ALDL frames in VB

Post by pman92 »

Not exactly what your after but have a look here
viewtopic.php?f=7&t=5165&p=88125#p88110
VR-VY Holden BCM Simulator: View Post
MrModule.com.au
Majinsoftware
Posts: 8
Joined: Wed Aug 28, 2013 4:33 pm
cars: delco

Re: Reading ALDL frames in VB

Post by Majinsoftware »

Thanks, pman92. That has some good info there.
Iv got a sample module put together for my dyno datalogging software. Now I just need a car to test it on or some one thats kind enough to do a raw serial log of aldl communication that I can use to make a simulator out of.
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Reading ALDL frames in VB

Post by antus »

the xdl format is pretty basic, you can grab some random logs from this site, look in side and you should see device id, length, and then the packets, then time and counter or similar, then the next packet. you can grab some sample packets out of them then feed the data in to tunerpro as it requests packets from your simulator to test it.
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
Post Reply