Exemplo n.º 1
0
        public static FtdUsbPort CreateAndOpenUsbPort(uint index)
        {
            FtdUsbPort port = new FtdUsbPort();
            port.OpenByIndex(index);

            return port;
        }
Exemplo n.º 2
0
		public void OpenByIndex()
		{
			using (var port = new FtdUsbPort())
			{
				port.OpenByIndex(0);
				Assert.IsTrue(port.IsOpen);
			}
		}
Exemplo n.º 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);
			}
		}
Exemplo n.º 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);
			}
		}
Exemplo n.º 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);
			}
		}
Exemplo n.º 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 });
            }
        }