예제 #1
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
 public HomeController(LordOfLittleComponentsContext context)
 {
     _context             = context;
     _serialPortConnector = new SerialPortConnector();
 }
 public HomeController(ILogger <HomeController> logger)
 {
     _logger = logger;
     _serialPortConnector = new SerialPortConnector();
 }
예제 #6
0
 public ParkingMjestoController(MyContext context)
 {
     _context             = context;
     _serialPortConnector = new SerialPortConnector();
 }
 private void _update_com()
 {
     cbb_comport.DataSource = SerialPortConnector.getAvalComPort();
 }
예제 #8
0
 public HomeController(MyContext context)
 {
     _context             = context;
     _serialPortConnector = new SerialPortConnector();
 }