//private char[] HexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
privatevoidserialPort1_DataReceived(objectsender, SerialDataReceivedEventArgs e)
{
char
hexH;
char
hexL;
byte
receivebyte;
string
dataToshow =
""
;
while
(serialPort1.BytesToRead > 0)
{
receivebyte = (
byte
)serialPort1.ReadByte();
hexH = HexChar[receivebyte / 16];
hexL = HexChar[receivebyte % 16];
dataToshow += hexH.ToString() + hexL.ToString();
}
this
.tBox.Invoke(
new
MethodInvoker(
delegate
{
this
.tBox.AppendText(dataToshow +
"\n"
);
}));
}