private void buttonOpenClose_Click(object sender, EventArgs e) { if (_serial_modbus == null) { _serial_driver = new PackedSerialPort(); _serial_driver.StateIsChanged += this.serialPortStateIsChanged; byte id = Convert.ToByte(textBoxNetId.Text); _serial_modbus = new SerialModbusDevice(_serial_driver, id); _table_shell = new MiniModbusDeviceTableShell(_serial_modbus); _table_shell.TablesWereCreated += deviceWasChanged; } if (_serial_driver.IsOpen()) { _serial_modbus.StopCommunication(); _serial_driver.Close(); textBoxNetId.Enabled = true; } else { if (comboBoxAvailablePortList.SelectedItem != null) { int speed = Utility.ConvertSpeed(comboBoxAvailableSpeeds.SelectedItem.ToString()); if (speed >= 0) { byte id = Convert.ToByte(textBoxNetId.Text); _serial_modbus.ChangeID(id); _serial_driver.Open(comboBoxAvailablePortList.SelectedItem.ToString(), speed); textBoxNetId.Enabled = false; } } } }
private void buttonOpenClose_Click(object sender, EventArgs e) { if (_serial_modbus == null) { _serial_driver = new PackedSerialPort(); _serial_driver.StateIsChanged += this.serialPortStateIsChanged; _serial_modbus = new SerialModbusDevice(_serial_driver, 1); _table_shell = new MiniModbusDeviceTableShell(_serial_modbus); _table_shell.TablesWereCreated += deviceWasChanged; _serial_modbus.readingIsComplete += readingIsComplete; } if (_serial_driver.IsOpen()) { _serial_modbus.StopCommunication(); _serial_driver.Close(); } else { if (comboBoxAvailablePortList.SelectedItem != null) { _serial_driver.Open(comboBoxAvailablePortList.SelectedItem.ToString(), 115200); } } }
private void start_serial_communication() { _serial_driver = new PackedSerialPort(); _serial_driver.StateIsChanged += this.serialPortStateIsChanged; _serial_modbus = new SerialModbusDevice(_serial_driver, (byte)board_settings.__bus_id); _table_shell = new MiniModbusDeviceTableShell_ExternalControl(_serial_modbus, board_settings); _table_shell.TablesWereCreated += deviceWasChanged; _serial_driver.Open(board_settings.serial_port, 115200); }
private void buttonOpenClose_Click(object sender, EventArgs e) { if (_port.IsOpen()) { _port.Close(); } else { if (comboBoxAvailablePortList.SelectedItem != null) { int speed = Utility.ConvertSpeed(comboBoxAvailableSpeeds.SelectedItem.ToString()); if (speed >= 0) { _port.Open(comboBoxAvailablePortList.SelectedItem.ToString(), speed); } } } }