以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]怎么将串口接受的字节数组显示出来  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96822)

--  作者:jolay0827
--  发布时间:2017/2/28 14:18:00
--  [求助]怎么将串口接受的字节数组显示出来
新手啊,正在垦荒中、、、、还有getstring()这个命令怎么不能用。
--  作者:jolay0827
--  发布时间:2017/2/28 14:31:00
--  
Dim cnt As Integer = e.Port.BytesToRead
If cnt > 0 Then \'缓冲区是否有数据
    Dim Val(cnt - 1) As Byte
      e.Port.Read(val,0,cnt)
      MessageBox.Show(e.Port.ReadByte)
End If


我用信息窗口只能显示两个也有点迷糊,还有 我能否用 getstring(val(cnt - 1 ) 就整个字节数组转换成字符串~

--  作者:有点色
--  发布时间:2017/2/28 14:43:00
--  

参考

 

Dim cnt As Integer = e.Port.BytesToRead
If cnt > 0 Then \'缓冲区是否有数据
    Dim Val(cnt - 1) As Byte
    e.Port.Read(val,0,cnt)
    For i As Integer = 0 to cnt-1
        msgbox(val(i))
    Next  
End If

--  作者:jolay0827
--  发布时间:2017/2/28 17:31:00
--  
xiexiele