Esempio n. 1
0
        private void processInputData(byte[] data)
        {
            //  _convertedBuffer += System.Text.Encoding.UTF8.GetString(data);
            //printInputData(System.Text.Encoding.UTF8.GetString(data));
            string hex = ByteFormatting.ByteToHex(data);

            byte lastByte = 0x00;

            foreach (byte d in data)
            {
                printInputData(ByteFormatting.ByteToHex(d) + " ");

                if (d == 0x0A && lastByte == 0x0D)
                {
                    printInputData(" > " + _convertedBuffer + Environment.NewLine + Environment.NewLine);
                    _convertedBuffer = "";
                }
                else
                {
                    _convertedBuffer += ((char)d).ToString();
                }
                lastByte = d;
            }

            //     string[] lines = hex.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            //     printInputData(ByteFormatting.ByteToHex(data, true));
        }
Esempio n. 2
0
        private void sendCommand()
        {
            string cmd = trimNewline(cmdInput.Text);

            if (cmd == "")
            {
                return;
            }

            cmdInput.Clear();

            updateHistory(cmd);

            if (chkAppendNewline.Checked)
            {
                _serialPort.Write(cmd + '\r');
            }
            else
            {
                _serialPort.Write(cmd);
            }

            consoleWriteLine(cmd + " (" + ByteFormatting.ByteToHex(ByteFormatting.GetBytes(cmd)).Replace("00", "") + ")" + Environment.NewLine, LinePrefixes.Output);
        }