private ErrorCode checkStartArgs(CanMessageSendTool can_tool, canMessage2 req, canMessageId resp_id) { ErrorCode err = ErrorCode.Ok; // check if (!m_self_test && (can_tool == null || !can_tool.IsSendingAllowed())) { // check the can tool (expect self_tests) err = ErrorCode.InvalidArg; } else if (req == null || resp_id == null) { // make sure we have not empty request and response err = ErrorCode.InvalidArg; } else if (req.Data.Count() == 0 || (req.Data.Count() + 1) > tx_message_len_max) { // check request data len (we do not support multi-frame sending) err = ErrorCode.InvalidArg; } else if (req.Id.Is29bit != resp_id.Is29bit) { // make sure request proto == response proto err = ErrorCode.InvalidArg; } else if (req.Data[0] == 0) { // requested service cannot be 0 err = ErrorCode.InvalidArg; } return(err); }
// start BMW public ErrorCode sendRequestBMW(CanMessageSendTool can_tool, byte ecu_id, List <byte> data) { const byte gateway_id = 0xF1; ErrorCode err = ErrorCode.Ok; // clean cleanData(); if (data.Count == 0) { return(ErrorCode.InvalidArg); } if (ecu_id == 0) { return(ErrorCode.InvalidArg); } // set specific configs for BMW tx_add_extra_bytes = false; m_req_prefix = new List <byte> { ecu_id }; m_resp_prefix = new List <byte> { gateway_id }; // prepare the request and response canMessage2 req = new canMessage2(createEcuAddressBmw(gateway_id), false, data.ToArray()); canMessageId resp_id = new canMessageId(createEcuAddressBmw(ecu_id), 1, false); // check the arguments err = checkStartArgs(can_tool, req, resp_id); // apply m_can_tool = can_tool; m_req_msg = req; m_resp_id = resp_id; // send the message if (err == ErrorCode.Ok) { m_expected_service = createExpectedService(data[0]); var uds_req = createRequestMessage(); if (uds_req == null) { err = ErrorCode.InvalidArg; } else { if (!sendRequest(uds_req)) { err = ErrorCode.TxFailed; } } } return(err); }
public ucActivationCodeSearcher(CanMessageSendTool canSendTool) { InitializeComponent(); CanTool = canSendTool; // this this.Dock = DockStyle.Fill; this.Margin = new Padding(0); // trace tbTrace.Dock = DockStyle.Fill; tbTrace.Multiline = true; tbTrace.ReadOnly = true; tbTrace.Margin = new Padding(0); tbTrace.ScrollBars = ScrollBars.Vertical; // can id numIdFrom.Maximum = canMessage.idMax(rb29BitId.Checked); numIdTo.Maximum = canMessage.idMax(rb29BitId.Checked); numIdFrom.Hexadecimal = true; numIdTo.Hexadecimal = true; numIdFrom.Minimum = 0; numIdTo.Minimum = 0; numIdFrom.Value = canMessage.idMax(rb29BitId.Checked); numIdTo.Value = 0; tbBusSleep.KeyPress += Tools.textBoxHexOnlyEvent; tbCount.KeyPress += Tools.textBoxHexOnlyEvent; tbIdCheck.KeyPress += Tools.textBoxHexOnlyEvent; numIdFrom.Font = new Font("Consolas", 9.0f, FontStyle.Italic); numIdFrom.TextAlign = HorizontalAlignment.Right; numIdTo.Font = numIdFrom.Font; numIdTo.TextAlign = numIdFrom.TextAlign; btnStartStop.Text = "Start"; tbCount.Text = "20"; tbBusSleep.Text = "3000"; tbData.Text = "00"; tbIdCheck.Text = "500"; tbTrace.Font = new Font("Consolas", 8.3f, FontStyle.Italic); // events rb11BitId.CheckedChanged += rbId_CheckedChanged; rb29BitId.CheckedChanged += rbId_CheckedChanged; }
// constructor public UcCanReadGrid(CanMessageSendTool can) { InitializeComponent(); this.Dock = DockStyle.Fill; grid = new canDataGrid(this); CanTool = can; // menu contextMenu.Items.Add("Hide Backlighted"); contextMenu.Items.Add("Hide all but Backlighted"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Hide Selected"); contextMenu.Items.Add("Hide all but Selected"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Hide all"); contextMenu.Items.Add("UnHide all"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Toggle Checkbox for All"); contextMenu.Items.Add("Toggle Checkbox for Selected"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Copy Selected"); contextMenu.Items.Add("Copy All"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Save Selected"); contextMenu.Items.Add("Save All"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Copy Selected as Script"); contextMenu.Items.Add("Copy All as Script"); contextMenu.Items.Add(new ToolStripSeparator()); //contextMenu.Items.Add("Copy Selected for Remoto"); //contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Send Selected"); // set it grid.contextMenuStrip = contextMenu; }
// start UDS public ErrorCode sendRequest(CanMessageSendTool can_tool, canMessage2 req, canMessageId resp_id) { ErrorCode err = ErrorCode.Ok; // clean and set cleanData(); // check the arguments err = checkStartArgs(can_tool, req, resp_id); // apply m_can_tool = can_tool; m_req_msg = req; m_resp_id = resp_id; // send the message if (err == ErrorCode.Ok) { m_expected_service = createExpectedService(req.Data[0]); var uds_req = createRequestMessage(); if (uds_req == null) { err = ErrorCode.InvalidArg; } else { if (!sendRequest(uds_req)) { err = ErrorCode.TxFailed; } } } return(err); }
public UcSendMessage(CanMessageSendTool canSendTool) { InitializeComponent(); this.Dock = DockStyle.Fill; this.Margin = new Padding(20, 20, 20, 20); CanTool = canSendTool; this.sender = new canSender(this); grid.Dock = DockStyle.Fill; grid.ContextMenuStrip = contextMenu; contextMenu.Items.Add("New message"); contextMenu.Items.Add("Edit Selected"); contextMenu.Items.Add("Delete Selected"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Enable All"); contextMenu.Items.Add("Disable All"); contextMenu.Items.Add("Delete All"); contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add("Copy Selected"); contextMenu.Opening += ContextMenu_ContextMenuOpening; contextMenu.ItemClicked += onContextMenuClicked; items = new List <canSendWorker>(); //gbAddMessage.Margin = new Padding(20); // features: refular and RTR message // trigger: timer, RTR response, on data // create grid: //checkbox (en/dis), type, id, dlc, data, interval, count, sent, remain guiCreateGrid(); }
// the region contains a class constructor #region Constructor // constructor public UcCanTrace(CanMessageSendTool can) { InitializeComponent(); // parent CanTool = can; // grid createGrid(); // menu createMenu(); grid.ContextMenuStrip = menu; // send tool sendWrkr = new canTraceUtils.sendWorker(CanTool, this); mode = traceMode.pause; //ts = new canTraceUtils.timestamp(); ts = new canTraceUtils.timestamp_offset(); conv = new canTraceUtils.mConverter(); conv.TS = ts; tbPlayFrom.KeyPress += Tools.textBoxIntOnlyEvent; tbPlayTo.KeyPress += Tools.textBoxIntOnlyEvent; updateMsgCounter(); cbTraceMode.Items.Add("All"); cbTraceMode.Items.Add("Selected"); cbTraceMode.SelectedIndex = 0; // icons btnTrace.Image = Properties.Resources.icon_record; btnSendStep.Image = Properties.Resources.icon_step; btnPlay.Image = Properties.Resources.icon_play; btnClear.Image = Properties.Resources.icon_clear; btnSendStep.Enabled = false; btnPlay.Enabled = false; btnSendRange.Enabled = false; btnClear.Enabled = false; tbPlayFrom.Enabled = btnPlay.Enabled; tbPlayTo.Enabled = btnPlay.Enabled; lblSendFrom.Enabled = btnPlay.Enabled; lblSendTo.Enabled = btnPlay.Enabled; lblSendFrom.Font = new Font("Consolas", 9, FontStyle.Italic); lblSendTo.Font = lblSendFrom.Font; cbTraceMode.Font = new Font("Consolas", 8f); lblTotalMsgs.Font = new Font("Calibri", 9.0f); foreach (DataGridViewColumn col in grid.Columns) { col.HeaderCell.Style.Font = new Font("Calibri", 9.0f, FontStyle.Bold); } grid.DefaultCellStyle.Font = new Font("Consolas", 8.5f);//, FontStyle.Italic); // System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip(); // ToolTip1.SetToolTip(this.btnTrace, "Start/Stop Recording"); }