Receipt of HEX Via TCP

Asked

Viewed 33 times

0

I need to convert a string that has been converted to HEX and sent via TCP to string.

I tried the 2 ways below and only get string unscathed :

public async void HandleConnections(TcpClient client)
{
  using (var networkStream = client.GetStream())
  {
    using (var reader = new StreamReader(networkStream))
    {

    returndata = await reader.ReadLineAsync();

    }

  }

}

public async void HandleConnections(TcpClient client)
{
    byte[] bytes = new byte[client.ReceiveBufferSize];

    string returndata = Encoding.UTF8.GetString (bytes);

    Console.WriteLine (returndata);
}
  • You can put an example of the original string and the converted string to HEX?

  • This device you are sending is a GPS tracker, in contact with the manufacturer the most I am informed is that it is sent in HEX format. I’m getting an ineligible string.

  • I am receiving this 78-78-0D-01-03-56-80-32-10-10-31-86-00-15-67-B2-0D-0A byte sequence

  • HEX is just a representation. You will always receive a sequence of bytes. If it sent the bytes representing HEX characters it should send only bytes with values from 60 to 71 (X30 to x39) and 101 to 106 (x41 to x46) because this, converted, would represent the possible characters of HEX. By the sequence you put is strange pq characters 00 until 32 (x00 to X20) are ASCII control characters and are not visible. Try to get more information from the manufacturer.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.