how can I display data, I received on SerialPort, in a raw hex byte format ?
It took me several approaches to convert the data basically, but there still seems to be an ASCII / UTF7 / UTF8 problem. I am now using a byte array instead of a former char-array, but still I don't get any value larger than 127 dec (0x7F). When sending decimal 128, I receive 0x3F on RX-Side.
Here's the current DataReceiveHandler:
|
Does anybody know how to display the hex values for incoming bytes from 0x80 up to 0xFF ?
Hansi MausiPosted Sep 7, 2010, 4:42 AM
I have to use
Here's the code:
{
Thread.Sleep(200);
string bytestr = "";
int numbytes = _portB.BytesToRead;
byte[] rxbytearray = new byte[numbytes];
for(int i = 0; i
rxbytearray[i] = (byte)_portB.ReadByte();
}
string hexvalues = "";
foreach (byte b in rxbytearray)
{
if(b != '\r')
hexvalues = hexvalues + (b.ToString("X2")) + " ";
}
UpdGuiEvent.Invoke(hexvalues);
}