Question Receiving data from serial port then into array.

Sythe

Member
Joined
Jul 18, 2012
Messages
13
Programming Experience
Beginner
Hey guys, can you help me on my problem. The program (RFID) im working on can only read one data at a time from serial port. What i need is for it to read 5 data at a time.
Scenario is this, it will read 5 RFID tags at a time. Then the value of the first tag will be put into textbox1, then the second will be put into textbox 2, and so on until all tags are read.
Here is the code of the program wherein it reads the data it receives.

  • VB.NET:
    Private Sub serialPort1_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
            Dim rx As Integer
            rx = SerialPort1.BytesToRead
            Dim comBuff As Byte() = New Byte(rx - 1) {}
            SerialPort1.Read(comBuff, 0, rx)
            txtRxData.Invoke(New DisplayDelegate(AddressOf DisplayCharacter), New Object() {BytetoHex(comBuff)})
        End Sub
 
Back
Top