T
tzhumi
Hi all,
I have a class that creates an instance of the seril Port.
Every thing works fine except whenever I receive data I cannot display
the
recieved data. I get no errors but the recived data seems to be empty.
when I try to display it in a text box nothing happens.
I have socket stuff in the same class and it's recieve callbacks work
just
fine and displays just fine.
Here is my code:
Sub OpenComPort()
Try
If Not SerialPort1.IsOpen Then
SerialPort1.PortName = cmbPorts.SelectedItem.ToString
If cmbBitRate.SelectedIndex > 0 Then
SerialPort1.BaudRate = CInt
(cmbBitRate.SelectedItem)
End If
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Open()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnOn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOn.Click
SendCommand("I2" + eot)
End Sub
Private Sub SendCommand(ByVal command As String)
Dim response As String = ""
SerialPort1.Write(command)
response = SerialPort1.ReadExisting
textbox1.text=response
End sub
When I send the command the controller responds to the command and it
should return the response by some ascii characters. But I am unable
to display the response from it...Thank you for any help
I have a class that creates an instance of the seril Port.
Every thing works fine except whenever I receive data I cannot display
the
recieved data. I get no errors but the recived data seems to be empty.
when I try to display it in a text box nothing happens.
I have socket stuff in the same class and it's recieve callbacks work
just
fine and displays just fine.
Here is my code:
Sub OpenComPort()
Try
If Not SerialPort1.IsOpen Then
SerialPort1.PortName = cmbPorts.SelectedItem.ToString
If cmbBitRate.SelectedIndex > 0 Then
SerialPort1.BaudRate = CInt
(cmbBitRate.SelectedItem)
End If
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Open()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnOn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOn.Click
SendCommand("I2" + eot)
End Sub
Private Sub SendCommand(ByVal command As String)
Dim response As String = ""
SerialPort1.Write(command)
response = SerialPort1.ReadExisting
textbox1.text=response
End sub
When I send the command the controller responds to the command and it
should return the response by some ascii characters. But I am unable
to display the response from it...Thank you for any help