using System.IO.Ports; namespace Tidstagning { class Relay { SerialPort com; public Relay(string ComPort) { com = new SerialPort(); com.PortName = ComPort; com.BaudRate = 9600; com.Open(); } public void Set(int output, byte state) { byte[] command = {0xff, 0x01, state}; com.Write(command, 0, 3); } public void Close() { if(com.IsOpen) com.Close(); } public static string[] GetPorts() { return SerialPort.GetPortNames(); } } }