Exemple #1
0
        private void checkHexS_CheckedChanged(object sender, EventArgs e)
        {
            var str = txtCmd.Text.Trim();

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            try
            {
                txtCmd.Text = checkHexS.Checked ? Convertor.Bytes2Hex(Encoding.UTF8.GetBytes(str)) : Convertor.Hex2String(str.Split(' '));
            }
            catch (Exception)
            {
                return;
            }
        }
Exemple #2
0
 private void txtStr_KeyUp(object sender, KeyEventArgs e)
 {
     if (string.IsNullOrEmpty(txtStr.Text))
     {
         return;
     }
     try
     {
         byte[] bits = Convertor.String2Bytes(txtStr.Text);
         txtAscii.Text = Convertor.Bytes2AsciiStr(bits);
         txtHex.Text   = Convertor.Bytes2Hex(bits);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #3
0
        private void appendReceiveData(byte[] buffer)
        {
            if (buffer == null)
            {
                appendCmdMsg("received null.");
                return;
            }
            var rec = Convertor.Bytes2Hex(buffer);

            if (checkAscii.Checked)
            {
                rec = Convertor.Bytes2AsciiStr(buffer);
            }
            if (checkStr.Checked)
            {
                rec = Convertor.Bytes2String(buffer);
            }
            txtReceive.AppendText(buildReceiveData(rec));
        }
Exemple #4
0
        void _spr_DataReceived(object sender, SerialDataReceivedEventArgs e, byte[] bits)
        {
            if (bits == null)
            {
                txtCmdMsg.Text = "received null.";
                return;
            }
            string rec = Convertor.Bytes2Hex(bits);

            if (checkAscii.Checked)
            {
                rec = Convertor.Bytes2AsciiStr(bits);
            }
            if (checkStr.Checked)
            {
                rec = Convertor.Bytes2String(bits);
            }
            listBox1.Items.Add(rec);
            //throw new NotImplementedException();
        }
Exemple #5
0
 public void BitConverter(byte[] bits)
 {
     Str = Convertor.Bytes2String(bits);
     Asc = Convertor.Bytes2AsciiStr(bits);
     Hex = Convertor.Bytes2Hex(bits);
 }