2024年6月5日发(作者:)
Imports
Imports
Public Class JCFrm
Dim RS232 As SerialPort
Private Sub JCFrm_Load(ByVal sender As , ByVal e As rgs)
Handles
Dim mBaudRate As Integer
Dim mParity As
Dim mDataBit As Integer
Dim mStopbit As ts
Dim mPortName As String
mPortName = "com1" '欲开启的通讯端口
mBaudRate = 9600 '比特率
mParity = '校验位检查设定
mDataBit = 8 '数据位设定值
mStopbit = '停止位设定值
'建立一个通讯端口对象
RS232 = New Port(mPortName, mBaudRate, mParity, mDataBit,
mStopbit)
If Not Then '尚未开启
() '开启通讯端口
Else
MsgBox("~~通讯端口已开启~~",
el)
End
End If
Private Sub readBtn1_Click(ByVal sender As , ByVal e As rgs)
Handles
Try
If = "读取" Then
al = 100
d = True
= "确定"
d = False '检测AW1的值,不能同时检测AW2的值。
ElseIf = "确定" Then
d = False
=
= "读取"
d = True
End If
Catch ex As Exception
al Or
("读取错误:" + ng, "错误通知",
, ation)
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As , ByVal e As rgs)
Handles
'Dim InString As String
'Dim start_str, end_str As String
'start_str = "55AA55AA04" '开头
'end_str = "0A" '结尾
'55 AA 55 AA 04 07 20 20 33 30 30 03 0A
'16进制:30-39为0-9,2e为小数点
Try
Dim inbyte() As Byte, readcount As Integer
If oRead <= 0 Then Exit Sub
ReDim Preserve inbyte(13) '声明数组空间
'调用read方法
readcount = (inbyte, 0, 13)
If readcount = 0 Then
Exit Sub
Else
For Each bdata As Byte In inbyte
+= ng & vbCrLf
Next
End If
Catch ex As Exception
("读取错误:" + ng,
, ation)
End Try
"错误通知",
发布评论