private static void Main(string[] args) { var ports = SerialPortDevice.GetPortNames(); SerialPortDevice port = new SerialPortDevice(null, "COM3", BitRate.B9600); //var port = new System.IO.Ports.SerialPort("/dev/ttyUSB0", 9600); /* * FE 05 00 00 FF 00 98 35 * FE 05 00 01 FF 00 C9 F5*/ //port.PortName = "/dev/ttyUSB0"; //port.BaudRate = 9600; port.Open(); var data = new byte[] { 0xFE, 0x05, 0x00, 0x01, 0xFF, 0x00, 0xc9, 0xf5 }; //FE 05 00 01 FF 00 C9 F5 port.Write(data); data = new byte[] { 0xFE, 0x05, 0x00, 0x00, 0x00, 0x00, 0xD9, 0xC5 }; port.Write(data); port.Close(); }
public DAM(ILogger logger, string comPath, byte address = 0xfe) { if (string.IsNullOrEmpty(comPath)) { throw new ArgumentException("message", nameof(comPath)); } Logger = logger; ComPath = comPath; this.address = address; var ports = SerialPortDevice.GetPortNames(); device = new SerialPortDevice(logger, comPath, BitRate.B9600); for (int i = 0; i < this.RelayPortsCount; i++) { RelayPort[i] = false; } for (int i = 0; i < this.OptocouplerPortsCount; i++) { OptocouplerPort[i] = false; } for (int i = 0; i < this.AnalogInputCount; i++) { AnalogInput[i] = 0; } device.Open(); }