7,765
社区成员
发帖
与我相关
我的任务
分享
Public Function ComSetting(ComNo As Integer)
On Error Resume Next
If MSComm_Ageing.CommPort <> ComNo Then
If MSComm_Ageing.PortOpen = True Then
MSComm_Ageing.PortOpen = False
End If
MSComm_Ageing.CommPort = ComNo
MSComm_Ageing.InputMode = comInputModeBinary '串口通信方式为2进制传送
MSComm_Ageing.InputLen = 0
MSComm_Ageing.InBufferSize = 512 '设置输入缓冲区字节数
MSComm_Ageing.InBufferCount = 0
MSComm_Ageing.OutBufferSize = 512 '设置输出缓冲区字节数
MSComm_Ageing.OutBufferCount = 0
MSComm_Ageing.RThreshold = 0 '允许驱动事件字节数
MSComm_Ageing.Settings = "28800,n,8,1"
If (ComNo = 1 Or ComNo = 4) Then
MSComm_Ageing.Settings = "9600,n,8,1"
Else
MSComm_Ageing.Settings = "19200,n,8,1"
End If
MSComm_Ageing.PortOpen = True
End If
End Function