public byte[] send_Hex(string text) { byte[] bt; Int16 crc_value; String_Handle str_hd = new String_Handle(); CRC_Handle crc = new CRC_Handle(); String str = String_Handle.del_noused_content(text); bt = String_Handle.StrTobyteArray(str); //bt = System.Text.Encoding.Default.GetBytes(str); if (bt == null) { return(bt); } else { if (check_type == 1)//crc { byte[] bt2 = new byte[bt.Length + 2]; for (int i = 0; i < bt.Length; i++) { bt2[i] = bt[i]; } crc_value = crc.CRC16(bt, bt.Length); bt2[bt.Length] = (byte)(crc_value % 256); bt2[bt.Length + 1] = (byte)(crc_value / 256); return(bt2); } else if (check_type == 2)//mod { byte[] bt2 = new byte[bt.Length + 1]; Byte check = new Byte(); check = 0; for (int i = 0; i < bt.Length; i++) { bt2[i] = bt[i]; check = (byte)(check + bt[i]); } bt2[bt.Length] = check; return(bt2); } else { byte[] bt2 = new byte[bt.Length]; for (int i = 0; i < bt.Length; i++) { bt2[i] = bt[i]; } return(bt2); } } }
public byte[] send_String(string text) { byte[] bt; String_Handle str_hd = new String_Handle(); String str = String_Handle.del_noused_content(text); bt = System.Text.Encoding.Default.GetBytes(str); return(bt); }