ALDL logger VB10

Programs / Tools / Scripts
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

ALDL logger VB10

Post by Tazzi »

Hi All, hoping this is the right section for this!
I've begun developing a new ALDL logging program in VB10. It is similar to VL400's fantastic ose tool (the aldl logging part) but I'm aiming to add few more filtering features to identify specific commands received after particular events. Filtering that is implemented so far includes device ID (F2,F1,40), as well as a frame counter to count the repetition of a command (See image).
Although Iv come across a serial retrieving issue, when sending single aldl frames, program works correctly and receives single aldl frame. (connected up to cluster/radio for testing)
But once plugging into the car and enabling car chatter, it seems to skip/miss parts of the frames (doesnt display whole frame), or the missed frame part is received on the next datareceived.event or just full stop doesnt display!
Program doesnt lag when logging, possibly have the wrong serialport configuration setup to handle the mass amount of information?
Below is picture of program at the moment.
Image

The serial port configuration I have at the moment is:

Code: Select all

SerialPort1.PortName = cmbPort.Text         'Set SerialPort1 to the selected COM port at startup
        SerialPort1.BaudRate = cmbBaud.Text         'Set Baud rate to the selected value on
  
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.DataBits = 8
        SerialPort1.Open()
And here is the datarecieved event called every-time data is sent back through serial:

Code: Select all

 Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
            Dim Count As Integer = SerialPort1.BytesToRead  'set count as the amount bytes to read
            Dim Buffer(0 To (Count - 1)) As Byte    'set buffer array
            Dim Text2Display As String = ""     'set as string
            Dim RecievedDisplay As String       'set as string
            SerialPort1.Read(Buffer, 0, Count)
            For I As Integer = 0 To Buffer.GetUpperBound(0)
                Text2Display += Buffer(I).ToString("X2") & " "  'adds recieved data to string
            Next
        RecievedDisplay = Text2Display
        DataSingleLine = RecievedDisplay
            ReceivedText(RecievedDisplay)    'Automatically called every time a data is received at the serialPort

Private Sub ReceivedText(ByVal [text] As String)

        Dim i As Integer = 0
        Dim FilterString As String
        Dim CheckFilterChange As String
        'compares the ID of the creating Thread to the ID of the calling Thread
        If Me.rtbReceived.InvokeRequired Then
        Dim x As New SetTextCallback(AddressOf ReceivedText)
        Me.Invoke(x, New Object() {(text) & vbNewLine})
           Else
            If ComboBoxDeviceId.Text = "Nill" Then 'checks if there is a filter
            Me.rtbReceived.AppendText([text] & vbNewLine) 'to rtbrecieved

            Else
                CheckFilterChange = ComboBoxDeviceId.Text 'Grabs current filter
                If CheckFilterChange = "Custom" Then    'checks if its custom filter
                    CheckFilterChange = TextBoxCustomFilter.Text 'takes custom device filter
                    FilterString = [text].Trim 'removes any spaces at front and back
                    FilterString = FilterString.Substring(0, 2) 'takes first 2 characters
                    If CheckFilterChange = FilterString Then 'displays if returns positive
                    Me.rtbReceived.AppendText([text] & vbNewLine) 'to rtbrecieved
                    End If
             
   Else
                    FilterString = [text].Trim 'removes any spaces at front and back
                    FilterString = FilterString.Substring(0, 2) 'takes first 2 characters
                    If CheckFilterChange = FilterString Then 'displays if returns positive
                    Me.rtbReceived.AppendText([text] & vbNewLine) 'to rtbrecieved
                    End If
                End If
            End If
           
    End Sub
All comments , feedback is appreciated! Will take some images of the program's receiving issue with the car chatter soon.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
VX L67 Getrag
Posts: 2877
Joined: Sun Aug 02, 2009 9:16 pm
Location: Bayside, Melbourne, Victoria
Contact:

Re: ALDL logger VB10

Post by VX L67 Getrag »

WAY over my head but looks pretty tidy, guessing the issue when connected to car will be something to do with heartbeat or similar?
yoda69
Posts: 1215
Joined: Sun Mar 15, 2009 10:20 am
cars: 2004 VYII Acclaim Wagon V6 Auto LPG/Petrol
2004 VYII Berlina sedan V6 Auto
2005 VZ Monaro CV8 manual
Location: Geelong, VIC

Re: ALDL logger VB10

Post by yoda69 »

I'm very interested in this, just finished installing 2010 VB Express and was planning on something similar to start with then add ability to send commands with user input (commanded AFR, etc.) similar to efi live. Was also hoping to do act on received string. I think my ambitions may be above my programming skill levels, but will have to wait and see, biggest problem will be getting spare time between work and family commitments.
Yoda69
User avatar
VL400
Posts: 4991
Joined: Sun Mar 01, 2009 2:54 pm
cars: VL Calais and Toyota Landcruiser. Plus some toys :)
Location: Perth, WA
Contact:

Re: ALDL logger VB10

Post by VL400 »

Excellent project tazzi :thumbup: will be very handy. I have also found the same thing with VB (well .net) missing some frames, the listen for chatter function in the flashtool is still not perfect in that regard. Same goes for sending frames, VB does not always send frames exactly when you ask it to start.
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: ALDL logger VB10

Post by Tazzi »

Well at least its not just me that has this issue! will need to play with the serial port settings/buffer settings, possibly need another filter searching for nonsense? haha
Good to see interest yoda69! The "act on a string received" is actually what I'm aiming to do now.. its also the issue I am getting, as the received messages are not always correct! Hoping to add another filter to search for particular strings then pass them on to another table for modification "if receivedstring = "F1 blah blah" then..."
It doesn't miss a beat when sending the commands(least thats sorted), I have a serial port monitor running that shows what is sent and received across the serial.

I think the next course of action (unless someone has a suggestion?), is to strip away any filer ect, have the bare basics for just the serialport.open() and serialport.close() and see if the messages are correct.
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
VL400
Posts: 4991
Joined: Sun Mar 01, 2009 2:54 pm
cars: VL Calais and Toyota Landcruiser. Plus some toys :)
Location: Perth, WA
Contact:

Re: ALDL logger VB10

Post by VL400 »

Tazzi wrote:It doesn't miss a beat when sending the commands(least thats sorted), I have a serial port monitor running that shows what is sent and received across the serial.
If you have a scope, depending on the PC speed if you use detect silence of say 50ms after a heartbeat frame then fire off a disable chatter command the 50ms varied (randomly) by a reasonable amount - sometimes enough to cause a collision with the next frame that was on the bus, ie it was sent late by over 70ms. I am using VB 2008,not sure if the newer .net versions have improved this but something to be aware of if your getting no responses or weird bus issues.
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: ALDL logger VB10

Post by Tazzi »

Ah VL400 your brilliant!!, I didn't think to send off a disable chatter command!
Then send off the user's desired command then pick up the device response. (Im sure Ill find out with trial and error) but device should respond to a command during the disabled chatter? or will it be the first (or one of the first) responses once chatter starts back up (or once I enable it).

Im using VB 10, figured using the newest should give some benefits. Hopefully by stripping the serial port data sent/received coding (remove filter/counter.. could be affecting values/performance?) along with disabling chatter will sort out obtaining correct values when connected to car obd port. Strange it only happens once connected to the car port.. does perfectly fine when connected directly to cluster or radio. Also thinking of computer speed, probably should test this after compiling and running exe alone... may be lagging due to debugging.

Will continue testing :D
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: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: ALDL logger VB10

Post by Tazzi »

Well after a few hours of key smashing rage, I figured out the only single part of my code letting me down was:

Code: Select all

Me.rtbReceived.AppendText([text] & vbNewLine)
For some unknown reason the vbnewline would randomly lose bytes or would display them underneath the frame received.
Am now using a list view to display the text, seems to work flawlessly!.

Need to re-implement the frame counter and a few other tweaks such as removing the echo of the frame sent.

VL400, by the looks of it, your program "searches" for the reply, seems its filtering the responses for the device ID?
Also assuming the filter ignores any responses that are the same as sent.
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
VL400
Posts: 4991
Joined: Sun Mar 01, 2009 2:54 pm
cars: VL Calais and Toyota Landcruiser. Plus some toys :)
Location: Perth, WA
Contact:

Re: ALDL logger VB10

Post by VL400 »

Interesting, good work on solving it! Prob the same issue I have as it also uses vbnewline in the chatter window.

Correct, I use filtering on frames for everything except the listen to chatter part which is just whatever frames are on the bus. On vehicles with lots of chatter it made a difference in searching for the heartbeat and helped to get the return frames once chatter is disabled.
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: ALDL logger VB10

Post by Tazzi »

Not sure why the vbnewline was giving hassle, probably work if I had the ALDL frame sent to chatter window by it self then send the vbnewline. But ill just leave it since its working at the moment.

So bit of an update to it, got the filters up and running, looks for heart beat then displays chatter, so all sweet there!
The "Listen to chatter" does have a couple of filters hooked up to it if desired to be used.

Seem to get a few threading errors with the frame counter though so thatll need to be sorted.

Need a For/While loop for the ALDL frame send as Iv noticed that sometimes a response is not picked up first go with alot of chatter happening. Im assuming the filters are not slowing the program down enough to miss the received frames although it seems to be fine in that regards!
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
Post Reply