private void PortName_Clicked(object sender, EventArgs e) { try { ToolStripMenuItem item = sender as ToolStripMenuItem; if (item == null) { return; } if (item.Text == "Test") { InitTestPort(); return; } if (item.Text == "Telnet") { InitTelnet(); return; } IO.SerialIOPort port = Session.Transport as IO.SerialIOPort; if (port == null) { int baudRate = 9600; IO.SerialIOPort p = Session.Transport as IO.SerialIOPort; if (p != null) { baudRate = p.BaudRate; } port = new IO.SerialIOPort(); port.BaudRate = baudRate; } port.Address = item.Text; if (port.Status == ConnectionStatusCodes.Connected) { port.Disconnect(); } Session.Transport = port; port.Connect(); UpdateStatus(); } catch (Exception ex) { Crt.Print(ex.Message); } }
private void BaudRate_Clicked(object sender, EventArgs e) { ToolStripMenuItem button = sender as ToolStripMenuItem; if (button == null) { return; } IO.SerialIOPort port = Session.Transport as IO.SerialIOPort; if (port == null) { return; } int baud = int.Parse(button.Text); //port.Disconnect(); port.BaudRate = baud; //port.Connect(); UpdateStatus(); }
public void UpdatePortMenu() { if (Session.Transport == null) { return; } IO.SerialIOPort sp = Session.Transport as IO.SerialIOPort; if (sp == null) { BitsDropdown.Visible = false; } else { BitsDropdown.Visible = true; if (sp.Port != null) { dataBits7.Checked = sp.Port.DataBits == 7; dataBits8.Checked = sp.Port.DataBits == 8; parityNoneToolStripMenuItem.Checked = sp.Port.Parity == System.IO.Ports.Parity.None; paritySpaceToolStripMenuItem.Checked = sp.Port.Parity == System.IO.Ports.Parity.Space; parityMarkToolStripMenuItem.Checked = sp.Port.Parity == System.IO.Ports.Parity.Mark; parityEvenToolStripMenuItem.Checked = sp.Port.Parity == System.IO.Ports.Parity.Even; parityOddToolStripMenuItem.Checked = sp.Port.Parity == System.IO.Ports.Parity.Odd; stop1ToolStripMenuItem.Checked = sp.Port.StopBits == System.IO.Ports.StopBits.One; stop2ToolStripMenuItem.Checked = sp.Port.StopBits == System.IO.Ports.StopBits.Two; } } if (Session.Terminal != null) { bitTrimToolStripMenuItem.Checked = Session.Terminal.TrimHighBit; } }