public IActionResult portSettings([FromBody] SerialConnectorModel input) { try { _serialPortConnector = new SerialPortConnector(input.baundRate, input.portName); return(Ok("port created")); } catch { return(BadRequest("failed")); } }
private bool _connect_to_serial() { try { if (_port_open) { _port.Close(); } _port = new SerialPort(); _baud_rate = cbb_baud_rate.SelectedItem as BaudRate; SerialPortConnector.SerialSetup(_port, cbb_comport.SelectedValue.ToString(), (cbb_baud_rate.SelectedValue as BaudRate)); _port.DataReceived += new SerialDataReceivedEventHandler(uart_data_received_handler); _port_open = _port.IsOpen; cbb_comport.Enabled = false; chart1.BorderlineColor = Color.LimeGreen; } catch (Exception) { chart1.BorderlineColor = Color.Red; return(false); } return(true); }
private bool _com_connect() { try { if (_port_open) { _port.Close(); } _port = new SerialPort(); _baud_rate = cbb_baud_rate.SelectedItem as BaudRate; SerialPortConnector.SerialSetup(_port, cbb_com_port.SelectedValue.ToString(), (cbb_baud_rate.SelectedValue as BaudRate)); _port.DataReceived += new SerialDataReceivedEventHandler(uart_data_received_handler); _port_open = _port.IsOpen; cbb_com_port.Enabled = false; btn_connect.Text = "Disconnect"; } catch (Exception) { _port_open = false; cbb_com_port.Enabled = true; btn_connect.Text = "Connect"; _checking_signal = false; MessageBox.Show("Error opening port", "Connection error"); return(false); } return(true); }
public HomeController(LordOfLittleComponentsContext context) { _context = context; _serialPortConnector = new SerialPortConnector(); }
public HomeController(ILogger <HomeController> logger) { _logger = logger; _serialPortConnector = new SerialPortConnector(); }
public ParkingMjestoController(MyContext context) { _context = context; _serialPortConnector = new SerialPortConnector(); }
private void _update_com() { cbb_comport.DataSource = SerialPortConnector.getAvalComPort(); }
public HomeController(MyContext context) { _context = context; _serialPortConnector = new SerialPortConnector(); }