版主请帮忙:485通讯中常温正常,高温实验,调试助手接收数据正常,VB做的前面会多几个FF

efengxu 2008-07-31 09:24:29
做串口通讯几年了,还是第一次遇到这个问题,常温用我的程序和串口调试助手都没问题
做高温实验时就遇到了这个问题,前面会多3,4个FF,但调试助手是正确的
...全文
346 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
efengxu 2008-08-07
  • 打赏
  • 举报
回复
不是接收的问题,后来查到问题了,是发送字节的问题
感谢 zdingyun 你发给我的串口调试精灵

用在普通232通讯中,我的发送是没问题的,在485中,可能由于不同种类的线,发送时可能线上会产生干扰
我改过发送发送后不存在这样的问题了

后来调试发现,串口调试助手也出现了FF,我的和调试助手出现了同样的问题

嗷嗷叫的老马 2008-08-05
  • 打赏
  • 举报
回复
哦哈哈~~~~~~~看来是接收的代码的问题!

顶一下!
zdingyun 2008-08-02
  • 打赏
  • 举报
回复
由于你接收代码的缺陷,在下位机处于高温时,其晶振时基发生改变返回的数据或许有停顿,导致接收出现多余字节。
调试发现:
我模拟下位机
先发送&HFF,上位机显示FF

再发送&HF1,上位机显示FFFFF1
问题就可能出在这里。

zdingyun 2008-08-02
  • 打赏
  • 举报
回复
接收代码有错误,修改如下:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim strJ As String '校验位
Dim bytS1(1 To 1) As Byte, bytS2(1 To 1) As Byte, bytS3(1 To 1) As Byte, bytS4(1 To 1) As Byte, bytS5(1 To 1) As Byte, bytS6(1 To 1) As Byte, bytS7(1 To 1) As Byte, bytS8(1 To 1) As Byte, bytS9(1 To 1) As Byte, bytS10(1 To 1) As Byte, bytS11(1 To 1) As Byte, bytS12(1 To 1) As Byte, bytS13(1 To 1) As Byte, bytS14(1 To 1) As Byte, bytS15(1 To 1) As Byte, bytS16(1 To 1) As Byte, bytS17(1 To 1) As Byte, bytS18(1 To 1) As Byte, bytS19(1 To 1) As Byte, bytS20(1 To 1) As Byte '发送字节
Dim bytS21(1 To 1) As Byte, bytS22(1 To 1) As Byte, bytS23(1 To 1) As Byte, bytS24(1 To 1) As Byte, bytS25(1 To 1) As Byte, bytS26(1 To 1) As Byte, bytS27(1 To 1) As Byte, bytS28(1 To 1) As Byte, bytS29(1 To 1) As Byte, bytS30(1 To 1) As Byte, bytS31(1 To 1) As Byte, bytS32(1 To 1) As Byte, bytS33(1 To 1) As Byte, bytS34(1 To 1) As Byte, bytS35(1 To 1) As Byte, bytS36(1 To 1) As Byte, bytS37(1 To 1) As Byte, bytS38(1 To 1) As Byte, bytS39(1 To 1) As Byte, bytS40(1 To 1) As Byte '发送字节
Dim intTim As Integer
Dim bytGet() As Byte
Dim bytGetAll(0 To 100000) As Long 'byte
Dim intNumI As Integer
Dim i As Integer
Private Sub Form_Load()
On Error GoTo errHand
Timer1.Enabled = False
intTim = 1
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = 1 'Right(Combo1.Text, 1)
MSComm1.Settings = "9600,N,8,1" 'Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
Pic.BackColor = vbRed
'Pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
MsgBox Err.Description
End Sub


Private Sub cmdOpen_Click() '打开
On Error GoTo errHand
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = 1 'Right(Combo1.Text, 1)
MSComm1.Settings = "9600,N,8,1" 'Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除

If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
Pic.BackColor = vbRed
'Pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MsgBox "可能的错误原因是:" + Err.Description
End Sub

Private Sub cmdF_Click() '发送
' Dim lngLen As Long
Dim strText As String
Dim bytGet() As Byte
Dim bytG(10000) As Byte
On Error GoTo errHand
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
End If
intNumI = 0
txtRec.Text = ""
'statBar.Panels.Item(1) = "0 字节"
If txtSend = "" Then
Exit Sub
End If
strText = Replace(txtSend.Text, " ", "")
Dim i As Integer
For i = 1 To Len(strText) Step 2
bytS1(1) = "&H" & Mid(strText, i, 2)
' Debug.Print Mid(strText, i, 2)
MSComm1.Output = bytS1
Next
MSComm1.InBufferCount = 0 '清除发送缓冲区
MSComm1.OutBufferCount = 0 '清除接收缓冲区
'TimeDelay 200'080801

MSComm1.RThreshold = 1

Timer1.Enabled = True
Exit Sub
errHand:
MsgBox Err.Description
End Sub

Private Sub MSComm1_OnComm()
Dim bytGet() As Byte
Dim intDateLen As Long '数据块长度
Select Case MSComm1.CommEvent
Case comEvReceive
Timer1.Enabled = False
bytGet = MSComm1.Input
For i = 0 To UBound(bytGet)
If Len(Hex(bytGet(i))) = 1 Then
txtRec.Text = txtRec.Text + "0" + Hex(bytGet(i)) ' + " "
Else
txtRec.Text = txtRec.Text + Hex(bytGet(i)) '+ " "
End If
Next
End Select
Exit Sub
End Sub
嗷嗷叫的老马 2008-08-01
  • 打赏
  • 举报
回复
真是奇怪!!

但仔细一想,会不会是这样的可能:

80度温度下工作的设备,发送过来的东西都带了FF,只是串口调试助手给处理了?

不知道你的那个工具在查看串口时要不要占用串口;

要不这样,你下载一个超级单片机开发工具看看:

http://www.sydzdiy.com/down/soft/05102918260087443_45652.html

它的串口调试功能是基于文件系统过滤驱动的,可以实时显示你的软件到设备间的通讯过程,而不占用串口.

这样的话把范围缩小些.
efengxu 2008-08-01
  • 打赏
  • 举报
回复
这个是我自己写的一个测试用的调试程序,就一个界面,里面代码如下:
如果你有qq,我可以把这个程序传给你,你帮我看下哪里需要改动的
谢谢了
Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim strJ As String '校验位
Dim bytS1(1 To 1) As Byte, bytS2(1 To 1) As Byte, bytS3(1 To 1) As Byte, bytS4(1 To 1) As Byte, bytS5(1 To 1) As Byte, bytS6(1 To 1) As Byte, bytS7(1 To 1) As Byte, bytS8(1 To 1) As Byte, bytS9(1 To 1) As Byte, bytS10(1 To 1) As Byte, bytS11(1 To 1) As Byte, bytS12(1 To 1) As Byte, bytS13(1 To 1) As Byte, bytS14(1 To 1) As Byte, bytS15(1 To 1) As Byte, bytS16(1 To 1) As Byte, bytS17(1 To 1) As Byte, bytS18(1 To 1) As Byte, bytS19(1 To 1) As Byte, bytS20(1 To 1) As Byte '发送字节
Dim bytS21(1 To 1) As Byte, bytS22(1 To 1) As Byte, bytS23(1 To 1) As Byte, bytS24(1 To 1) As Byte, bytS25(1 To 1) As Byte, bytS26(1 To 1) As Byte, bytS27(1 To 1) As Byte, bytS28(1 To 1) As Byte, bytS29(1 To 1) As Byte, bytS30(1 To 1) As Byte, bytS31(1 To 1) As Byte, bytS32(1 To 1) As Byte, bytS33(1 To 1) As Byte, bytS34(1 To 1) As Byte, bytS35(1 To 1) As Byte, bytS36(1 To 1) As Byte, bytS37(1 To 1) As Byte, bytS38(1 To 1) As Byte, bytS39(1 To 1) As Byte, bytS40(1 To 1) As Byte '发送字节
Dim intTim As Integer
Dim bytGet() As Byte
Dim bytGetAll(0 To 100000) As Long 'byte


Private Sub Form_Load()
On Error GoTo errHand
Timer1.Enabled = False
Select Case Combo3.Text
Case "无NONE"
strJ = "N"
Case "奇ODD"
strJ = "O"
Case "偶EVEN"
strJ = "E"
End Select
intTim = 1
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = Right(Combo1.Text, 1)
MSComm1.Settings = Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
MsgBox Err.Description
End Sub

Private Sub cmdEmp_Click()
txtSend.Text = ""
End Sub

Private Sub cmdREmp_Click() '清空接收区
txtRec.Text = ""
End Sub


Private Sub Combo3_Click() '校验
On Error GoTo errHand
Select Case Combo3.Text
Case "无NONE"
strJ = "N"
Case "奇ODD"
strJ = "O"
Case "偶EVEN"
strJ = "E"
End Select
Exit Sub
errHand:
MsgBox "可能的错误原因是:" + Err.Description
End Sub

Private Sub cmdOpen_Click() '打开
On Error GoTo errHand
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = Right(Combo1.Text, 1)
MSComm1.Settings = Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除

If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
pic.Picture = LoadPicture(App.Path & "\blue.jpg")
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MsgBox "可能的错误原因是:" + Err.Description
End Sub

Private Sub cmdF_Click() '发送
' Dim lngLen As Long
Dim strText As String
Dim bytGet() As Byte
Dim bytG(10000) As Byte
On Error GoTo errHand
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
End If
intNumI = 0
txtRec.Text = ""
statBar.Panels.Item(1) = "0 字节"
If txtSend = "" Then
Exit Sub
End If
strText = Replace(txtSend.Text, " ", "")
For i = 1 To Len(strText) Step 2
bytS1(1) = "&H" & Mid(strText, i, 2)
' Debug.Print Mid(strText, i, 2)
MSComm1.Output = bytS1
Next
MSComm1.InBufferCount = 0 '清除发送缓冲区
MSComm1.OutBufferCount = 0 '清除接收缓冲区
TimeDelay 200

MSComm1.RThreshold = 1

Timer1.Enabled = True
Exit Sub
errHand:
MsgBox Err.Description
End Sub

Private Sub MSComm1_OnComm()
Dim intDateLen As Long '数据块长度
On Error GoTo errHand
Select Case MSComm1.CommEvent
Case comEvReceive
Timer1.Enabled = False
bytGet = MSComm1.Input
For i = 0 To UBound(bytGet)
bytGetAll(intNumI + i) = bytGet(i)
Next
intNumI = intNumI + UBound(bytGet) + 1
statBar.Panels.Item(1) = CStr(intNumI) & " 字节"
Timer1.Enabled = True
Case comEventBreak
Debug.Print comEventBreak
Case comEventCDTO ' CD (RLSD) 超时。
Debug.Print comEventCDTO
Case comEventCTSTO ' CTS Timeout。
Debug.Print comEventCTSTO
Case comEventDSRTO ' DSR Timeout。
Debug.Print comEventDSRTO
Case comEventFrame ' Framing Error
Debug.Print comEventFrame
Case comEventOverrun '数据丢失。
Debug.Print comEventOverrun
Case comEventRxOver '接收缓冲区溢出。
Debug.Print comEventRxOver
Case comEventRxParity ' Parity 错误。
Debug.Print comEventRxParity
Case comEventTxFull '传输缓冲区已满。
Debug.Print comEventTxFull
Case comEventDCB
Debug.Print comEventDCB
Case comEvCD ' CD 线状态变化。
Debug.Print comEvCD
Case comEvCTS ' CTS 线状态变化。
Debug.Print comEvCTS
Case comEvDSR ' DSR 线状态变化。
Debug.Print comEvDSR
Case comEvRing ' Ring Indicator 变化。
Debug.Print comEvRing
Case comEvSend ' 传输缓冲区有 Sthreshold 个字符 '
Debug.Print comEvSend '
Case comEvEOF ' 输入 End Select
Debug.Print comEvEOF
Case Else
Debug.Print MSComm1.CommEvent
End Select
Exit Sub
errHand:
MsgBox "可能的错误描述:" + Err.Description
End Sub

Private Sub Timer1_Timer()
On Error GoTo errHand
Timer1.Enabled = False
For i = 0 To intNumI - 1
If Len(Hex(bytGetAll(i))) = 1 Then
txtRec.Text = txtRec.Text + "0" + Hex(bytGetAll(i)) + " "
Else
txtRec.Text = txtRec.Text + Hex(bytGetAll(i)) + " "
End If
DoEvents
Next
txtRec.SelStart = Len(txtRec)
txtRec.SelLength = 0
txtRec.SetFocus
Exit Sub
errHand:
MsgBox "可能的错误描述:" + Err.Description
End Sub
zdingyun 2008-08-01
  • 打赏
  • 举报
回复
LZ:
我想你应该将你自己的代码贴出,并详细说明通信协议。
efengxu 2008-08-01
  • 打赏
  • 举报
回复
zdingyun & myjian
两位版主能否留个QQ或者msn?想请教下这个问题
efengxu 2008-08-01
  • 打赏
  • 举报
回复
各位不好意思,家里不能上网,早上到公司才看到你们的回的消息,
一到公司我就试了下超级单片机工具,是能正确接收到数据的
这个工具是VB写的嘛?但我怎样才能找我的问题呢?
zdingyun :你的串口调试精灵我收到了,好像不能更改串口号和校验位?我改下试试看

谢谢你们的帮主,万分感谢,

我的问题还没解决呢
Paro 2008-08-01
  • 打赏
  • 举报
回复
学习中。。
zdingyun 2008-08-01
  • 打赏
  • 举报
回复
仔细看了你的代码,接收部分过于繁琐,不够简练,现修改代码如下:

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim strJ As String '校验位
Dim bytS1(1 To 1) As Byte, bytS2(1 To 1) As Byte, bytS3(1 To 1) As Byte, bytS4(1 To 1) As Byte, bytS5(1 To 1) As Byte, bytS6(1 To 1) As Byte, bytS7(1 To 1) As Byte, bytS8(1 To 1) As Byte, bytS9(1 To 1) As Byte, bytS10(1 To 1) As Byte, bytS11(1 To 1) As Byte, bytS12(1 To 1) As Byte, bytS13(1 To 1) As Byte, bytS14(1 To 1) As Byte, bytS15(1 To 1) As Byte, bytS16(1 To 1) As Byte, bytS17(1 To 1) As Byte, bytS18(1 To 1) As Byte, bytS19(1 To 1) As Byte, bytS20(1 To 1) As Byte '发送字节
Dim bytS21(1 To 1) As Byte, bytS22(1 To 1) As Byte, bytS23(1 To 1) As Byte, bytS24(1 To 1) As Byte, bytS25(1 To 1) As Byte, bytS26(1 To 1) As Byte, bytS27(1 To 1) As Byte, bytS28(1 To 1) As Byte, bytS29(1 To 1) As Byte, bytS30(1 To 1) As Byte, bytS31(1 To 1) As Byte, bytS32(1 To 1) As Byte, bytS33(1 To 1) As Byte, bytS34(1 To 1) As Byte, bytS35(1 To 1) As Byte, bytS36(1 To 1) As Byte, bytS37(1 To 1) As Byte, bytS38(1 To 1) As Byte, bytS39(1 To 1) As Byte, bytS40(1 To 1) As Byte '发送字节
Dim intTim As Integer
Dim bytGet() As Byte
Dim bytGetAll(0 To 100000) As Long 'byte
Dim intNumI As Integer
Dim i As Integer
Private Sub Form_Load()
On Error GoTo errHand
Timer1.Enabled = False
Select Case Combo3.Text
Case "无NONE"
strJ = "N"
Case "奇ODD"
strJ = "O"
Case "偶EVEN"
strJ = "E"
End Select
intTim = 1
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = Right(Combo1.Text, 1)
MSComm1.Settings = "9600,N,8,1" 'Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
Pic.BackColor = vbRed
'Pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
MsgBox Err.Description
End Sub

Private Sub cmdEmp_Click()
txtSend.Text = ""
End Sub

Private Sub cmdREmp_Click() '清空接收区
txtRec.Text = ""
End Sub

Private Sub Combo3_Click() '校验
On Error GoTo errHand
Select Case Combo3.Text
Case "无NONE"
strJ = "N"
Case "奇ODD"
strJ = "O"
Case "偶EVEN"
strJ = "E"
End Select
Exit Sub
errHand:
MsgBox "可能的错误原因是:" + Err.Description
End Sub

Private Sub cmdOpen_Click() '打开
On Error GoTo errHand
If cmdOpen.Caption = "打 开" Then
cmdOpen.Caption = "关 闭"
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MSComm1.CommPort = Right(Combo1.Text, 1)
MSComm1.Settings = "9600,N,8,1" 'Combo2.Text & strJ & Combo4 & Combo5 '波特率9600,N为奇校验,8个数据位,1个停止位
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0 '读取整个接收缓冲区内码或消除

If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
Pic.BackColor = vbRed
'Pic.Picture = LoadPicture(App.Path & "\red.jpg")
End If
Else
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
cmdOpen.Caption = "打 开"
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
End If
Exit Sub
errHand:
Pic.BackColor = vbBlue
'Pic.Picture = LoadPicture(App.Path & "\blue.jpg")
If MSComm1.PortOpen = True Then '端口未打开
MSComm1.PortOpen = False
End If
MsgBox "可能的错误原因是:" + Err.Description
End Sub

Private Sub cmdF_Click() '发送
' Dim lngLen As Long
Dim strText As String
Dim bytGet() As Byte
Dim bytG(10000) As Byte
On Error GoTo errHand
If MSComm1.PortOpen = False Then '端口未打开
MSComm1.PortOpen = True
End If
intNumI = 0
txtRec.Text = ""
'statBar.Panels.Item(1) = "0 字节"
If txtSend = "" Then
Exit Sub
End If
strText = Replace(txtSend.Text, " ", "")
Dim i As Integer
For i = 1 To Len(strText) Step 2
bytS1(1) = "&H" & Mid(strText, i, 2)
' Debug.Print Mid(strText, i, 2)
MSComm1.Output = bytS1
Next
MSComm1.InBufferCount = 0 '清除发送缓冲区
MSComm1.OutBufferCount = 0 '清除接收缓冲区
'TimeDelay 200'080801

MSComm1.RThreshold = 1

Timer1.Enabled = True
Exit Sub
errHand:
MsgBox Err.Description
End Sub

Private Sub MSComm1_OnComm()
Dim intDateLen As Long '数据块长度
On Error GoTo errHand
Select Case MSComm1.CommEvent
Case comEvReceive
Timer1.Enabled = False
bytGet = MSComm1.Input
For i = 0 To UBound(bytGet)
bytGetAll(intNumI + i) = bytGet(i)
Next
intNumI = intNumI + UBound(bytGet) + 1
'statBar.Panels.Item(1) = CStr(intNumI) & " 字节"'080801
Timer1.Enabled = True
End Select
Exit Sub
errHand:
MsgBox "可能的错误描述:" + Err.Description
End Sub

Private Sub Timer1_Timer()
'On Error GoTo errHand
Timer1.Enabled = False
Dim i As Integer
For i = 0 To intNumI - 1
If Len(Hex(bytGetAll(i))) = 1 Then
txtRec.Text = txtRec.Text + "0" + Hex(bytGetAll(i)) ' + " "
Else
txtRec.Text = txtRec.Text + Hex(bytGetAll(i)) '+ " "
End If
'DoEvents'080801
Next
'txtRec.SelStart = Len(txtRec)
'txtRec.SelLength = 0
'txtRec.SetFocus
'Exit Sub
'errHand:
' MsgBox "可能的错误描述:" + Err.Description
End Sub

代码中的:
Dim bytS1(1 To 1) As Byte, bytS2(1 To 1) As Byte, bytS3(1 To 1) As Byte, bytS4(1 To 1) As Byte, bytS5(1 To 1) As Byte, bytS6(1 To 1) As Byte, bytS7(1 To 1) As Byte, bytS8(1 To 1) As Byte, bytS9(1 To 1) As Byte, bytS10(1 To 1) As Byte, bytS11(1 To 1) As Byte, bytS12(1 To 1) As Byte, bytS13(1 To 1) As Byte, bytS14(1 To 1) As Byte, bytS15(1 To 1) As Byte, bytS16(1 To 1) As Byte, bytS17(1 To 1) As Byte, bytS18(1 To 1) As Byte, bytS19(1 To 1) As Byte, bytS20(1 To 1) As Byte '发送字节
Dim bytS21(1 To 1) As Byte, bytS22(1 To 1) As Byte, bytS23(1 To 1) As Byte, bytS24(1 To 1) As Byte, bytS25(1 To 1) As Byte, bytS26(1 To 1) As Byte, bytS27(1 To 1) As Byte, bytS28(1 To 1) As Byte, bytS29(1 To 1) As Byte, bytS30(1 To 1) As Byte, bytS31(1 To 1) As Byte, bytS32(1 To 1) As Byte, bytS33(1 To 1) As Byte, bytS34(1 To 1) As Byte, bytS35(1 To 1) As Byte, bytS36(1 To 1) As Byte, bytS37(1 To 1) As Byte, bytS38(1 To 1) As Byte, bytS39(1 To 1) As Byte, bytS40(1 To 1) As Byte '发送字节
我的意见应定义为BYTE数组。
此外,未见接收正确数据的判断及数据处理。
efengxu 2008-07-31
  • 打赏
  • 举报
回复
版主能否帮忙 解决下啊?谢谢啊?

人在哪里呢?
zdingyun 2008-07-31
  • 打赏
  • 举报
回复
LZ:
发的邮件不知道收到没有?
efengxu 2008-07-31
  • 打赏
  • 举报
回复
我在发送完字节后加
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
Sleep (500)
收到的效果会好点
efengxu 2008-07-31
  • 打赏
  • 举报
回复
我们把设备放入高温箱里,温度有80几度,测试条件肯定是相同的
我也是头一次遇到这个问题,但用调试助手就是能正确上载,用VB写的程序就是不行,前面会多几个FF
嗷嗷叫的老马 2008-07-31
  • 打赏
  • 举报
回复
晕,还头一次听说这情况!

你的意思是:

自己的软件在高温状态数据有问题,但串口调试助手在高温状态却正常??

软件运行时竟然受现实温度影响??

你确认你的软件高温时与串口调试助手的硬件条件相同?

864

社区成员

发帖
与我相关
我的任务
社区描述
VB COM/DCOM/COM+
c++ 技术论坛(原bbs)
社区管理员
  • COM/DCOM/COM+社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧