发送和接收字节紧急帮助

发送和接收字节紧急帮助

本文介绍了需要通过串行(VS2010)发送和接收字节紧急帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我必须执行以下操作

I know I have to do the following

1)发送数据:使用写入方法https://msdn.microsoft.com/zh-cn/library/ms143551%28v=vs.110%29.aspx

1) To send data: Use Write method https://msdn.microsoft.com/en-us/library/ms143551%28v=vs.110%29.aspx

2)接收数据:https://msdn.microsoft.com/zh-CN/library/system.io.ports.serialport.datareceived(v=vs.110).aspx

2) To receive data: https://msdn.microsoft.com/en-us/library/system.io.ports.serialport.datareceived(v=vs.110).aspx

(我不确定如何实现)

与此类似吗?

Private Sub serialPort1_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Dim rx As Integer
        rx = SerialPort1.BytesToRead

        if rx>=2 then
        Dim comBuff As Byte() = New Byte(rx - 1) {}
        SerialPort1.ReadByte(comBuff, 0, rx)
        tbRx.Invoke(New DisplayDelegate(AddressOf DisplayCharacter), New Object() {BytetoHex(comBuff)})

        end if
    End Sub


如何将值写入文本框?


How do write the the values to textbox?

非常感谢

推荐答案

这里有三个例子:
https://vbdotnetblog.wordpress.com/serial-port/

Three examples here:
https://vbdotnetblog.wordpress.com/serial-port/


这篇关于需要通过串行(VS2010)发送和接收字节紧急帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:03