我用vb编了一个串行发送的协议,用RS232和dsp通信的,我发出去,怎莫没有响应,dsp是没有错误的,波特率和校验也没有错误我用串口调试工具调试过DSP ,可以发送和接收。和DSP用RS232的2,3,5脚通信
但是相同的数据用我下面的程序dsp那边显示没有接收 ,
我将RS232的2和3脚短接,自己能接收到数据,但是dsp那边显示没有接收 ,这到底是怎摸回事。麻烦高手帮我看一下:
Private Sub Command1_Click()Dim dictate(15) As Byte
dictate(0) = &H68
dictate(1) = &HA
dictate(2) = &HA
dictate(3) = &H68
dictate(4) = &H4D
dictate(5) = &HFF
dictate(6) = &H77
dictate(7) = &H5
dictate(8) = 5
dictate(9) = &HFF
dictate(10) = &H5
dictate(11) = &H64
dictate(12) = 48
dictate(13) = 0
dictate(14) = 65H
dictate(15) = &H16If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
End If
MSComm1.Output = dictate ' 发送数据
End Sub‘----------------------------------------------------
Private Sub Form_Load() '初始化控件的属性
MSComm1.CommPort = 1MSComm1.Settings = "2400,E,8,1"MSComm1.InputLen = 0 MSComm1.RThreshold = 1 MSComm1.InBufferCount = 0 MSComm1.OutBufferCount = 0
End Sub
’--------------------------------------------------Private Sub MSComm1_OnComm() '接收程序 Dim arr As Variant
Dim buf() As Byte
Dim m As Integer
Dim n As IntegerSelect Case MSComm1.CommEvent Case comEvReceive
MSComm1.InputMode = comInputModeBinary If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
End If
'-----------------------------------------------------
n = MSComm1.InBufferCount
Print n
ReDim buf(0 To n - 1)
arr = MSComm1.Input
buf = arr Print buf(0) '用于验证是否接收到
Print buf(1)
Print buf(2)
Print buf(3)
Print buf(4)
Print buf(5)
Print buf(6)
Print buf(7)
Print buf(8)
Print buf(9)
Print buf(10)
Print buf(11)
Print buf(12)
Case Else
End Select
End Sub
但是相同的数据用我下面的程序dsp那边显示没有接收 ,
我将RS232的2和3脚短接,自己能接收到数据,但是dsp那边显示没有接收 ,这到底是怎摸回事。麻烦高手帮我看一下:
Private Sub Command1_Click()Dim dictate(15) As Byte
dictate(0) = &H68
dictate(1) = &HA
dictate(2) = &HA
dictate(3) = &H68
dictate(4) = &H4D
dictate(5) = &HFF
dictate(6) = &H77
dictate(7) = &H5
dictate(8) = 5
dictate(9) = &HFF
dictate(10) = &H5
dictate(11) = &H64
dictate(12) = 48
dictate(13) = 0
dictate(14) = 65H
dictate(15) = &H16If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
End If
MSComm1.Output = dictate ' 发送数据
End Sub‘----------------------------------------------------
Private Sub Form_Load() '初始化控件的属性
MSComm1.CommPort = 1MSComm1.Settings = "2400,E,8,1"MSComm1.InputLen = 0 MSComm1.RThreshold = 1 MSComm1.InBufferCount = 0 MSComm1.OutBufferCount = 0
End Sub
’--------------------------------------------------Private Sub MSComm1_OnComm() '接收程序 Dim arr As Variant
Dim buf() As Byte
Dim m As Integer
Dim n As IntegerSelect Case MSComm1.CommEvent Case comEvReceive
MSComm1.InputMode = comInputModeBinary If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
End If
'-----------------------------------------------------
n = MSComm1.InBufferCount
Print n
ReDim buf(0 To n - 1)
arr = MSComm1.Input
buf = arr Print buf(0) '用于验证是否接收到
Print buf(1)
Print buf(2)
Print buf(3)
Print buf(4)
Print buf(5)
Print buf(6)
Print buf(7)
Print buf(8)
Print buf(9)
Print buf(10)
Print buf(11)
Print buf(12)
Case Else
End Select
End Sub
解决方案 »
- 散分帖,为了热心帮助我的童鞋们!
- 一个奇怪的修改数据库中日期出现的问题.但是在XP上运行一切正常,在98上出错,先谢谢各位大哥了,给小弟看看,很急.
- DATAGRID里处理BIT类型字段的时候能不能显示为CHECK框样式?急!!!!!!!!!!
- 关于串口通信延时的问题,大家都来讨论!
- 女友问的问题,不知道该怎么回答,请大虾们帮忙
- 关于richtextbox的输入问题
- 请问rtsp://movie1.qu-zhou.com/mountpoint1/xfy02.rm
- 请问16进制数字转换成十进制数字的函数是什么?谢谢!
- 列表框的问题,很急~~~~呀!!!???
- 我会播放MID和WAV了!谢谢大家,可是怎么才能循球播放MID呢?我只会循球播放WAV:(
- 想问个关于PaintPicture的问题
- ?///我知道列举一个网页中全部文字的方法,但是怎样把那些“没用”的文字过滤掉,只显示“正文”?(wsshello)
MSComm1.InputMode = comInputModeBinary