vb.net串口通讯
TX=02 00 01 FE FF
RX=01 00 02 00 FD
com2 口 其他都默认。
如何实现?请教高手!
[解决办法]
Imports System.IO.Ports
Public Class Form1
Private MySerialport As New SerialPort("COM2")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MySerialport.Open()
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
MySerialport.ReadTo("01 00 02 00 FD") '默认代码是字符串格式
MySerialport.Write("02 00 01 FE FF")
End Sub
End Class