private void LEVBP_Packet_Unpack_button_Click(object sender, EventArgs e) { LEVBPReceivedDataDetector receiver = new LEVBPReceivedDataDetector(); List <LEVBPReceivedDataDetector.ReceivedPacket> packet = receiver.DataDetector(MassUtilities.HexStringToByteArray(LEVBP_Packet_textBox.Text)); LEV_Unpacking_textBox.Text = ("=============================" + Environment.NewLine); foreach (LEVBPReceivedDataDetector.ReceivedPacket p in packet) { LEV_Unpacking_textBox.AppendText("RX Cmd : " + String.Format("0x{0:X}", p.Cmd) + Environment.NewLine); string data = MassUtilities.ByteArrayToHexString(p.Data, true); LEV_Unpacking_textBox.AppendText("RX data : " + data + Environment.NewLine); LEV_Unpacking_textBox.AppendText("RX data type : " + p.Type + Environment.NewLine); LEV_Unpacking_textBox.AppendText("=============================" + Environment.NewLine); } }
private void OneWire_eepromData_Set_button_Click(object sender, EventArgs e) { //detection packet string str = MassUtilities.StringTrim_Replace_EnterAndTab_CombineMultiSpaceToOne(OneWire_EEpromData_textBox.Text); LEVBPReceivedDataDetector receiver = new LEVBPReceivedDataDetector(); List <LEVBPReceivedDataDetector.ReceivedPacket> packets = receiver.DataDetector(MassUtilities.HexStringToByteArray(str)); bool find_data_flag = false; byte[] find_data = new byte[0]; foreach (LEVBPReceivedDataDetector.ReceivedPacket packet in packets) { if (packet.Type == LEVBPReceivedDataDetector.RespondedDataType.LEV_ST_G2_OneWire_EEPROM) { find_data = packet.Data; find_data_flag = true; break; } } if (!find_data_flag) { OneWire_eeprom_infor_textBox.Text = ("Cannot find EEprom Data packet (structure)." + Environment.NewLine); return; } g_Owdr.SetData(LEV_ST_G2_OneWireDataResolution.DataGroup.EepromData, find_data); LEV_ST_G2_OneWireDataResolution.DetailOfItem[] items; items = g_Owdr.GetAllItemInfor(typeof(LEV_ST_G2_OneWireDataResolution.ItemNameOfEepromData)); OneWire_eeprom_infor_textBox.Text = ("==============================================" + Environment.NewLine); foreach (LEV_ST_G2_OneWireDataResolution.DetailOfItem item in items) { OneWire_eeprom_infor_textBox.AppendText(item.Name.PadRight(58) + "= " + item.Values.ToString().PadRight(10) + "(type = " + item.Type + ")" + Environment.NewLine); } OneWire_eeprom_infor_textBox.AppendText("==============================================" + Environment.NewLine); }