示例#1
0
        public string ReadHex()
        {
            byte [] data = m_ComPort.ReadInputBufferHex();

            string        hexSTR     = "";
            StringBuilder strBuilder = new StringBuilder();


            for (int i = 0; i < data.Length; i++)
            {
                // string message = string.Format("data[{0}] = {1} str = {2}", data[i], Convert.ToInt32(data[i]),  string.Format("{0:X}",data[i]));
                //  MessageBox.Show(message);
                //  strBuilder.Append("0x");
                string newByte = string.Format("{0:X2}", data[i]);
                //MessageBox.Show(newByte);
                strBuilder.Append(newByte);
                hexSTR = strBuilder.ToString();
                //   MessageBox.Show(hexSTR);
            }
            // string message = string.Format("INFO: Hex command invalid:{0} {1}", data.Length,hexSTR);

            // MessageBox.Show(hexSTR);
            return(hexSTR);
        }