//private char[] HexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

 private void serialPort1_DataReceived(object sender, 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");
            }));
        }

  

相关文章:

  • 2021-06-21
  • 2022-12-23
  • 2021-10-20
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-05-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-02-22
  • 2022-03-06
  • 2022-12-23
相关资源
相似解决方案