Home > Software engineering >  VB.Net a serial port receive less than data
VB.Net a serial port receive less than data

Time:10-01

To send data
 '
Private Sub senddata_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles senddata publishes the event. Click
Dim strincoming As String
Dim xx As String
Dim yy As String
Try
SerialPort1. Write (senddata publishes the event. The Text, 0, 4)
Threading. Thread.sleep (1000)
If SerialPort1. BytesToRead & gt; 0 Then
Threading. Thread.sleep (100) 'add delay
Strincoming=SerialPort1. ReadExisting. ToString 'data in a read buffer
SerialPort1. DiscardInBuffer ()
RXbox. Text=strincoming

End the If

Catch the ex As Exception
MessageBox. Show (ex. Message)
End the Try
End Sub


Procedure as above senddata publishes the event to send data, RXbox for receiving data frame, a serial port has been opened, use a serial port assistant debug can transmit and receive, your program of senddata publishes the event enter 1 to receive RXbox are empty inside, please teach the master

CodePudding user response:

The same problem don't need to ask twice, see: http://bbs.csdn.net/topics/390985158? Page=1 # post - 398891893
  •  Tags:  
  • VBA