用Visual Basic 5.0开发无线通讯数据采集应用程序
BinDataarr = BinData
UserDataLenth = BinDataarr(5) '用户数据的长度
Wait1:
If BinDataarr(5) > frmTerminal.MSComm1.InBufferCount Then '未接受完数据
delay 6 '延时6s
GoTo Wait1
End If
frmTerminal.MSComm1.InputLen = UserDataLenth
BinData = frmTerminal.MSComm1.Input
ReDim Preserve BinDataarr(UserDataLenth)
&nbs
p;BinDataarr = BinData
GetStringFromComm = BinTotext(UserDataLenth, 0)
frmTerminal.MSComm1.InBufferCount = 0 '清空接受缓冲区
End Function
2 从串口向电台发送数据程序SendStringToComm()
Public Sub SendStringToComm(ByVal TransCommand As Integer, ByVal TransString As String)
ReDim BinDataarr(5)
frmTerminal.MSComm1.OutBufferCount = 0 '//清空发送缓冲区
'TransString = makestring(Val(mc.txtdesstation.Text), 4) + TransString
'//设置标志码
(略)
Select Case TransCommand
Case 0:transmit text
ReDim Preserve BinDataarr(6 + Len(TransString))
TextTobin (TransString)
BinData = BinDataarr
frmTerminal.MSComm1.Output = BinData '发送
Case 1:transmit binary data
ReDim Preserve BinDataArr(5 + Len(TransString) + UserDataLenth) As Byte
TextTobin (TransString)
BinDataArr(5) = UserDataLenth + Len(TransString)
Dim i As Integer
For i = 1 To UserDataLenth
BinDataArr(5 + Len(TransString) + 《用Visual Basic 5.0开发无线通讯数据采集应用程序(第2页)》