How to receive via Hexadecimal serial information in C #

1

I'm starting an application that gets via the data from an interface in Hexadecimal, but when the data arrives, they are not shown in a Hexa format, it seems to me that they are being converted to ASCII. For example: the data is sent in the format by the interface 0B 01 10 2D 0D DC F2 and in the application are inserted in the listbox - ?? .

Is there any way to filter this and display the data in the listbox as the interface has been sent?

Below is the part of the code that is responsible for receiving the data.

// ************** DELAGATE DA THREAD ********************* //         public void serialCom_DataReceived (object sender, SerialDataReceivedEventArgs e)
        {             this.Invoke (new EventHandler (this.ReceptionSerial));         }

    //************** RECEPÇÃO DE DADOS *********************//
    public void RecepcaoSerial(object s, EventArgs e)
    {

        Thread.Sleep(800);
        bufferRx += serialCom.ReadExisting();

        byte[] rawBytes = System.Text.Encoding.ASCII.GetBytes(bufferRx);
        string str = BitConverter.ToString(rawBytes);
        str = BitConverter.ToString(rawBytes).Replace("-", " ");

        lstDadosEnviados.Items.Add(str);
        lstDadosEnviados.SelectedIndex = lstDadosEnviados.Items.Count - 1;
        lstDadosEnviados.SelectedIndex = -1;

        bufferRx = null;

    }
    
asked by anonymous 13.09.2017 / 12:16

0 answers