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.
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()
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