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; } }
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; } }
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)); }
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(); }
public void BitConverter(byte[] bits) { Str = Convertor.Bytes2String(bits); Asc = Convertor.Bytes2AsciiStr(bits); Hex = Convertor.Bytes2Hex(bits); }