public static FtdUsbPort CreateAndOpenUsbPort(uint index)
        {
            FtdUsbPort port = new FtdUsbPort();
            port.OpenByIndex(index);

            return port;
        }
Exemple #2
0
		public void OpenByIndex()
		{
			using (var port = new FtdUsbPort())
			{
				port.OpenByIndex(0);
				Assert.IsTrue(port.IsOpen);
			}
		}
Exemple #3
0
		public void OpenBySerialNumber()
		{
			var deviceInfo = FtdUsbPort.GetDeviceInfo(0);
			Assert.IsNotNull(deviceInfo);

			using (var port = new FtdUsbPort())
			{
				port.OpenBySerialNumber(deviceInfo.SerialNumber);
				Assert.IsTrue(port.IsOpen);
			}
		}
Exemple #4
0
		public void OpenByDescription()
		{
			var deviceInfo = FtdUsbPort.GetDeviceInfo(0);
			Assert.IsNotNull(deviceInfo);

			using (var port = new FtdUsbPort())
			{
				port.OpenByDescription(deviceInfo.Description);
				Assert.IsTrue(port.IsOpen);
			}
		}
Exemple #5
0
		public void OpenByLocationId()
		{
			var deviceInfo = FtdUsbPort.GetDeviceInfo(0);
			Assert.IsNotNull(deviceInfo);

			using (var port = new FtdUsbPort())
			{
				port.OpenByLocationId(deviceInfo.LocationId);
				Assert.IsTrue(port.IsOpen);
			}
		}
Exemple #6
0
        /// <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 });
            }
        }