C# - Decoding server response (Octet, hex, floating point)

  • Thread starter Thread starter Guilherme_
  • Start date Start date
G

Guilherme_

Guest
Hello.

I am communicating with a server via Socket. Where I send commands and receive responses from that server.

To decode the response from the server, I'm using the following:


string returndata = BitConverter.ToString (bytesToRead, 0, bytesRead) .Replace ("-", "");

Complete server response:

02010205144009232308393401092044E19D47EF409E47349B9D47830B0948E2E10848C55708482E3D1B41C4CC27414E9A3541A89968400D8936C9434E3CC9FD3F54C9D4C511CA11895CC8255FA9C846AD87C87AA84FC9407A3F49E2754F49769B5F49E6A21B4A1BAE3E49DC784E49D8D35E49BABD1A4AE5A78B4746D0A147FA429547925D6148AF10753FD579693F07D9733FB829713F4C4C4C4C680B743F145D683F57FF723F9CC66F3F7E3123430CC91B437A462243004DEE41403870420100000000000000000E000000005073F0C22E3AEF425073F0C28152F0C22E3AEFC2FDC7A43F519C783F62BCA13F0000000000000000000000000000000000000000000000FBC002000004

From that response, I need to extract information, in which the manual says the following:


From Octet 052 to 055: Active power phase A (IEEE floating point - 754 in 32 bits)

Assuming that 1 octet is 2 positions (I'm not sure). Then from Octet 52 to 55 the result would be: 0D8936C9. Which I believe to be a hexadecimal number. Converting to floating point: 8.45.

Is that it or am I doing it all wrong?

Continue reading...
 
Back
Top