private void bgTransmit_DoWork(object sender, DoWorkEventArgs e) { CanData can = e.Argument as CanData; GenericCanBus.GenericCanTransmitSingle(can); }
// Transmits the selected packets private void Transmit_Click(object sender, EventArgs e) { try { CanData can = new CanData(); string msgOutput = ""; // Loop through all items the MonitorBox. for (int x = 0; x < TransmitBox.Items.Count; x++) { // Determine if the item is selected. if (TransmitBox.Items[x].Selected) { can.hardware = TransmitInterfaceBox.SelectedItem.ToString(); can.format = "hex"; can.flags = 0; int count = 1; // Transmit for simple packets if (TransmitBox.Items[x].SubItems[1].Text.Contains("Packet")) { // return string --> 0=id; 1=dlc; 2=flag; 3=message msgOutput = XMLInterfaces.ReturnPacketDataTransmit(TransmitList.SelectedItem.ToString(), TransmitBox.Items[x].SubItems[0].Text); CommonUtils.ConvertStringtoCAN(can, msgOutput); string[] output = msgOutput.Split(';'); if (output[3].Equals("X")) { can.flags = 4; // Extended Packet } // if packets number or time between is blank then only send one packet if (output[4] == "" || output[5] == "") { GenericCanBus.GenericCanTransmitSingle(can); // Verbose Output if (VerboseTransmit.Checked == true) { MessageBox.Show(CommonUtils.DisplayMsg(can)); } } else { can.number = Convert.ToInt32(output[4]); can.timeBtw = Convert.ToInt32(output[5]); GenericCanBus.GenericCanTransmitMultiple(can); } // Transmit for Packet Sequences } else if (TransmitBox.Items[x].SubItems[1].Text.Contains("Sequence")) { // for execution once before the while check do { // return string --> 0=id; 1=dlc; 2=flag; 3=message msgOutput = XMLInterfaces.ReturnPacketDataSequence(count, TransmitList.SelectedItem.ToString(), TransmitBox.Items[x].SubItems[0].Text); if (msgOutput.Equals("??")) { return; } CommonUtils.ConvertStringtoCAN(can, msgOutput); string[] output = msgOutput.Split(';'); if (output[3].Equals("X")) { can.flags = 4; // Extended Packet } GenericCanBus.GenericCanTransmitSingle(can); count++; // Verbose Output if (VerboseTransmit.Checked == true) { MessageBox.Show(CommonUtils.DisplayMsg(can)); } } while (msgOutput.Contains(";")); } else if (TransmitBox.Items[x].SubItems[1].Text.Contains("If Then")) { MainWindow.ErrorDisplayString("If Then Clauses are Activated in the Bus Monitor User Interface"); } } } } catch { MessageBox.Show("No interface is turned on, please turn on the interfaces from \"Advanced Bus Control\""); this.Close(); BusControl form = (BusControl)CommonUtils.GetOpenedForm <BusControl>(); if (form == null) { form = new BusControl(); form.Show(); } else { form.Select(); } } }