这是那里的问题呢????
我做的是一个表决系统,用开发板编写的程序在上位机上都可以试验成功,但自己做的板子同意反对这两个数值都可以采集到上位机,但弃权怎么弄都采集不进去,(开发板用的是矩阵键盘,并且那个端口就只用做了按键。在我自己的板子上,用于弃权的按键是单独的,所以我想硬件没什么问题)并且我用的弃权=总人数-同意-反对所以说如果没有按键按下他发送回来的应该是弃权的值,但是还是不行,那位帮忙分析一下,谢了
下面是我采集下位机数据的程序:
Dim BytReceived() As Byte
Dim strBuff As Variant
Select Case MSComm1.CommEvent
Case 2
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
Dim i As Long
For i = 0 To UBound(BytReceived)
Debug.Print BytReceived(i)
Next
If i <= 2 Then
Text2 = BytReceived(0)
BytReceived(0) = 0
Else
tongyi = BytReceived(0)
BytReceived(0) = 0
fandui = BytReceived(2)
BytReceived(2) = 0
qiquan = BytReceived(4)
BytReceived(4) = 0
End If
End Select
[解决办法]
个人认为,你的用两个点来表示才行,没有按下去状态:0,按下去状态:1
那么:00:弃权;10:同意;01:反对。
[解决办法]
是不是没有接收完毕?
Do Until MSComm1.InBufferCount >= 5
DoEvents
Loop
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
......