public static FtdUsbPort CreateAndOpenUsbPort(uint index) { FtdUsbPort port = new FtdUsbPort(); port.OpenByIndex(index); return port; }
public void OpenByIndex() { using (var port = new FtdUsbPort()) { port.OpenByIndex(0); Assert.IsTrue(port.IsOpen); } }
public void OpenBySerialNumber() { var deviceInfo = FtdUsbPort.GetDeviceInfo(0); Assert.IsNotNull(deviceInfo); using (var port = new FtdUsbPort()) { port.OpenBySerialNumber(deviceInfo.SerialNumber); Assert.IsTrue(port.IsOpen); } }
public void OpenByDescription() { var deviceInfo = FtdUsbPort.GetDeviceInfo(0); Assert.IsNotNull(deviceInfo); using (var port = new FtdUsbPort()) { port.OpenByDescription(deviceInfo.Description); Assert.IsTrue(port.IsOpen); } }
public void OpenByLocationId() { var deviceInfo = FtdUsbPort.GetDeviceInfo(0); Assert.IsNotNull(deviceInfo); using (var port = new FtdUsbPort()) { port.OpenByLocationId(deviceInfo.LocationId); Assert.IsTrue(port.IsOpen); } }
/// <summary> /// Simple Modbus serial USB RTU master write multiple coils example. /// </summary> public static void ModbusSerialUsbRtuMasterWriteCoils() { using (FtdUsbPort port = new FtdUsbPort()) { // configure usb port port.BaudRate = 9600; port.DataBits = 8; port.Parity = FtdParity.None; port.StopBits = FtdStopBits.One; port.OpenByIndex(0); // create modbus master IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port); byte slaveId = 1; ushort startAddress = 1; // write three coils master.WriteMultipleCoils(slaveId, startAddress, new bool[] { true, false, true }); } }