Click here to Skip to main content
15,902,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
e.g "11101111" this is the data which i want to read it from serial port n after its conversion how to display its hex value ..
Posted

Depends on how it arrives at the sreail prot: if it arrives as a single byte, then just read that from the port, and set the TextBox.Text property:
C#
myTextBox.Text = myRecievedByte.ToString("X02");
If it arrives as a string of '0' and '1' characters then read the entire string and convert it first:
C#
byte myRecievedByte = Convert.ToByte(myRecievedString, 2);
 
Share this answer
 
C#
byte value = serialPort.ReadByte();
string hexString = value.ToString("x2");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900