帮忙看看为什么单片机接不到VB的数据

我在VB 6.0上模仿CH372DBG\DOWNFILE\WINDOWS下的Transfile函数,一直都接不到数据,头痛啊! 请指点一二!! Private Function TransFile(ByVal hWnd As Long) As Boolean

Dim ReadLen As Long Dim mLen As Long mLen = 0 Dim by As Byte Dim bylen As Long by = 0 bylen = 0 Trb = 0 Dim Writebuff As mBuff mTotal = 1 Writebuff.mBuff(0) = 0

Dim sb As OVERLAPPED With sb .Internal = 0 .InternalHigh = 0 .offset = 0 .OffsetHigh = 0 .hEvent = 0 End With 'Dim addr As Long Call CH375Writedata(0, mBuffer, mTotal) Do While (1) ReadLen = 1024 Call ReadFile(hWnd, mBuffer, 1024, ReadLen, sb)

If (ReadLen < 1024) Then mLen = ReadLen On Error Resume Next If (CH375Writedata(0, mBuffer, mLen)) Then If (mLen <> 0) Then Trb = Trb + 1 End If MsgBox "写结束 " & Trb & "K" Exit Do Else MsgBox "写数据失败" Exit Do End If Else mLen = ReadLen On Error Resume Next If (CH375Writedata(0, mBuffer, mLen)) Then If (mLen <> 0) Then Trb = Trb + 1 End If MsgBox "写结束 " & Trb & "K" Else MsgBox "写数据失败" ' Exit Do End If End If TransFile = False

'Else Loop 'Loop

End Function

用CH372DBG\DOWNFILE\WINDOWS程序是可以成功接收到文件的


你的基本数据通讯测试成功嘛?先要能做基本的传输数据,然后再去传输文件数据!还有你的文件读取正确嘛?一点一点的排除,肯定能找到原因!


只有登录才能回复,可以选择微信账号登录