Home > Software engineering >  How to use VB to realize serial communication, please?
How to use VB to realize serial communication, please?

Time:10-06

New talent contact VB in less than two or three days, because the task need emergency out of A simple VB program to realize serial communication, finish reading data curve function, the part chart yourself tossing out, serial part is stuck, development environment for VS2012, use SerialPort control implementation, serial part is very simple, only need to send an A, then recycling three hexadecimal return line, baud rate 9600. Excuse me, which can give A reference significance to the program, the younger brother was the feeling, to explain in detail to see which feature on the network, thank you all the QAQ

CodePudding user response:

No parity check some Settings, communication process is very simple,

CodePudding user response:

Have a ready-made controls may be used,

CodePudding user response:

I use is SerialPort controls, but encountered in receiving data is A little problem, is about A serial port interface A synchronous asynchronous delegate part of the above, my communication is sending instructions after A few seconds to return to the test results, this code can be?
Private Sub SerialPort1_DataReceived (ByVal sender As Object, ByVal e the As System. IO, Ports, SerialDataReceivedEventArgs) Handles SerialPort1. Method DataReceived
Dim n As Integer
Dim rxdata (2) the As Byte
SerialPort1. PortName="COM9"
N=Me. SerialPort1. BytesToRead
If (n & gt; 0) Then ReDim rxdata (n - 1)
Me. SerialPort1. Read (rxdata, 0, n)
SerialPort1. Close ()
End Sub

CodePudding user response:

VB.NET 2008 serial port engineering

CodePudding user response:

SerialPort1. Close ()
Closed,

Data may not arrive at a time,

CodePudding user response:

Mscomm control adopts event trigger mechanism, then data parsing
  •  Tags:  
  • VBA
  • Related