我的源码如下,请大神帮忙看看中间红色部分该如何处理取完整数据
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim S, S3, s1, flag, flag1 As String
Dim id, strlen As Integer
Dim tmp As String
Dim str() As Byte
Winsock1.getData str()
strdata = StrConv(str(), vbUnicode)
'转换为字符串,
flag = Left(strdata, 2)
'log.Text = log.Text & Format(Hour(Time), "00") & ":" & Format(Minute(Time), "00") & ":" & Format(Second(Time), "00") & " " & strdata
'显示日志
'log.SelStart = Len(log.Text)
Select Case flag
Case "E1"
'登录
Sleep 200
Login
'登录
log.Text = log.Text & Format(Hour(Time), "00") & ":" & Format(Minute(Time), "00") & ":" & Format(Second(Time), "00") & " " & "admin" & vbCrLf
'显示日志
Case "E0"
u = u + 1
log.Text = log.Text & Format(Hour(Time), "00") & ":" & Format(Minute(Time), "00") & ":" & Format(Second(Time), "00") & " " & strdata
'显示日志
log.SelStart = Len(log.Text)
If u = 1 Then
'
Sleep 500
log.Text = log.Text & Format(Hour(Time), "00") & ":" & Format(Minute(Time), "00") & ":" & Format(Second(Time), "00") & " " & "登录成功" & vbCrLf
'显示日志
state_lab = "TCP/IP Connect OK"
'登录成功
log.SelStart = Len(log.Text)
End If
Case "EA"
'温度值返回
S = strdata
log.Text = log.Text
'不显示日志
log.SelStart = Len(log.Text)
S3 = Split(S, "^C", , vbTextCompare)
For j = 1 To UBound(S3)
s1 = Split(S3(j), vbCrLf)(0)
s1 = Trim(s1)
If Format(s1) > Val(Form4.CH(j - 1)) Then
Form4.CH(j - 1) = Format(s1, "00.0")
End If
Next j
Case "EB"
'二进制数据返回,
tmp = StrConv(str(), vbUnicode)
id = str(9)
'取ID ,测试ok
strlen = HEX_to_DEC(Hex(str(4)) & Hex(str(5)) & Hex(str(6)) & Hex(str(7)))
'取数据长度,测试OK
在此位置该如何处理才能先接收全部的数据??
数据格式和使用Wireshark抓包的数据截图如下图
If id = 19 Then
'如果ID为19,则为设定信息输出
此处为对接收的数据进行处理,同上面温度值取出
End If
End Select
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
[
本帖最后由 hcyang1422 于 2015-4-23 12:48 编辑 ]