我用vb中 MSCOMM控件进行串口通讯,但是程序不产生oncomm事件,可能会是什么原因?谢谢!
下面是串口初始化: If MSComm1.PortOpen = False Then MSComm1.CommPort = 1 '设定Com1 MSComm1.Settings = "19200,n,8,1" '19200波特率,无校验,8位数据位,1位停止位 MSComm1.InBufferSize = 1024 '设置接收缓冲区的字节长度 MSComm1.PortOpen = True '打开串口 'Timer1.Enabled = True Command4.Caption = "关闭串口" Else: MSComm1.PortOpen = False '关闭串口 'Timer1.Enabled = False Command4.Caption = "打开串口" End If MSComm1.OutBufferCount = 0 '清空发送缓冲区 MSComm1.InBufferCount = 0 '滑空接收缓冲区 MSComm1.InputLen = 1 MSComm1.InputMode = comInputModeBinary '接收二进制数据 MSComm1.RThreshold = 1 MSComm1.SThreshold = 1
|