public SENSOR_OBJECT(EBaudRate BaudRate, string COM_port) { try { _BaudRate = ReturnStringBaudrate(BaudRate); _COMport = COM_port.Replace(" ", "").ToUpper(); string[] ports = SerialPort.GetPortNames(); if (!ports.Contains(_COMport)) throw new Exception("Com Port Not Available"); } catch (Exception Ex) { Function_CallError_Received(Ex.Message); } }
private string ReturnStringBaudrate(EBaudRate Baud) { switch (Baud) { case EBaudRate.Baud250000: { return("250000"); } case EBaudRate.Baud115200: { return("115200"); } case EBaudRate.Baud57600: { return("57600"); } case EBaudRate.Baud38400: { return("38400"); } case EBaudRate.Baud19200: { return("19200"); } case EBaudRate.Baud9600: { return("9600"); } case EBaudRate.Baud4800: { return("4800"); } default: { throw new Exception("Incorrect Baudrate"); } } }
public SENSOR_OBJECT(EBaudRate BaudRate, string COM_port) { try { _BaudRate = ReturnStringBaudrate(BaudRate); _COMport = COM_port.Replace(" ", "").ToUpper(); string[] ports = SerialPort.GetPortNames(); if (!ports.Contains(_COMport)) { throw new Exception("Com Port Not Available"); } } catch (Exception Ex) { Function_CallError_Received(Ex.Message); } }
private string ReturnStringBaudrate(EBaudRate Baud) { switch (Baud) { case EBaudRate.Baud250000: { return "250000"; } case EBaudRate.Baud115200: { return "115200"; } case EBaudRate.Baud57600: { return "57600"; } case EBaudRate.Baud38400: { return "38400"; } case EBaudRate.Baud19200: { return "19200"; } case EBaudRate.Baud9600: { return "9600"; } case EBaudRate.Baud4800: { return "4800"; } default: { throw new Exception("Incorrect Baudrate"); } } }