从网上下载的VB串口调试精灵的源码,使用后发现只能发送不能接收,这是什么原因呢,是不是还需要修改代码?我把部分代码给出
Private Sub ctrMSComm_OnComm()
Dim bytInput() As Byte '接收数据的数组
Dim intInputLen As Integer '记录数据的长度
Select Case frmMain.ctrMSComm.CommEvent
Case comEvReceive
If blnReceiveFlag Then '点击了接受数据,则打开串口
If Not frmMain.ctrMSComm.PortOpen Then
frmMain.ctrMSComm.CommPort = intPort
frmMain.ctrMSComm.Settings = strSet
frmMain.ctrMSComm.PortOpen = True
frmMain.ctrMSComm.RThreshold = 1
End If
frmMain.ctrMSComm.InputMode = comInputModeBinary '采用二进制方式
intInputLen = frmMain.ctrMSComm.InBufferCount '接受数据字符数的来源
ReDim bytInput(intInputLen) '重新定义这个接受数据数组的明确大小
bytInput = frmMain.ctrMSComm.Input '开始接受数据
Call InputManage(bytInput, intInputLen) '处理接收到的字节流,并保存在全局变量
'bytReceiveRyte()相当于把零散的数据汇合在大数组中
Call GetDisplayText
Call display
End If
End Select
End Sub
Private Sub ctrMSComm_OnComm()
Dim bytInput() As Byte '接收数据的数组
Dim intInputLen As Integer '记录数据的长度
Select Case frmMain.ctrMSComm.CommEvent
Case comEvReceive
If blnReceiveFlag Then '点击了接受数据,则打开串口
If Not frmMain.ctrMSComm.PortOpen Then
frmMain.ctrMSComm.CommPort = intPort
frmMain.ctrMSComm.Settings = strSet
frmMain.ctrMSComm.PortOpen = True
frmMain.ctrMSComm.RThreshold = 1
End If
frmMain.ctrMSComm.InputMode = comInputModeBinary '采用二进制方式
intInputLen = frmMain.ctrMSComm.InBufferCount '接受数据字符数的来源
ReDim bytInput(intInputLen) '重新定义这个接受数据数组的明确大小
bytInput = frmMain.ctrMSComm.Input '开始接受数据
Call InputManage(bytInput, intInputLen) '处理接收到的字节流,并保存在全局变量
'bytReceiveRyte()相当于把零散的数据汇合在大数组中
Call GetDisplayText
Call display
End If
End Select
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货