I am new to this forum and VB.net. I am current using VS2008 to write a little app to transmit hex data via the serial port to the target device and receive back data from it and display that on a text box.
The problem i am facing is receiving "read" data "hex" back from the serial port and displaying it. I am able to send data to the target system without any problem. For example, if i send this command "&H10, &H0, &H1, &H7E, &HFF, &H49" The LEDs on the system blink 10 times and it works every time. If i send this command "&H10, &H0, &H0, &HFF, &HD" i should get 5E back and I use Realterm to verify the communication and it works great. When i use my VB app it fails, instead of getting back 5E.I get "&H35, &H45, &HD, &HA" on the buffer
Could anyone give me some clues to why it's not working on my VB app but it works in Realterm
Private Sub sendbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sendbutton.Click
Dim send_Buffer() As Byte = {&H10, &H0, &H0, &HFF, &HD}
Dim receive_Buffer(255) As Byte
Dim receive_data As String
Dim display_txt As Integer
If SerialPort.IsOpen = False Then
SerialPort.Open()
End If
SerialPort.Write(send_Buffer, 0, send_Buffer.Length)
'display_txt = SerialPort.Read(receive_Buffer, 0, receive_Buffer.Length)
'SerialPort.Read(receive_Buffer, 0, receive_Buffer.Length)
SerialPort.Read(receive_Buffer, 0, receive_Buffer.Length)
Display_box.Text = Convert.ToDecimal(receive_Buffer)
End Sub
End Class

New Topic/Question
Reply




MultiQuote




|