示例#1
0
        public static async void OpenDevice(IFTDeviceInfoNode deviceInfo)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.CancelAfter(Timeout);
            var myDevice = ftManager.OpenByDescription(deviceInfo.Description);
            await myDevice.SetBaudRateAsync(9600);
            await myDevice.SetFlowControlAsync(FLOW_CONTROL.RTS_CTS, 0x00, 0x00);
            await myDevice.SetDataCharacteristicsAsync(WORD_LENGTH.BITS_8, STOP_BITS.BITS_1, PARITY.NONE);
            await myDevice.SetLatencyTimerAsync(16);
            var action = ThreadPool.RunAsync(async (source) => {
                byte[] dataTx = new byte[10]; for (int i = 0; i < dataTx.Length; i++) dataTx[i] = (byte)(i + 60);
                dataTx[7] = (byte)0;
                dataTx[8] = (byte)'\r';
                dataTx[9] = (byte)'\n';
                while (!cancellationTokenSource.Token.IsCancellationRequested)
                {
                    byte[] dataRx = new byte[10];
                    await myDevice.WriteAsync(dataTx, 10);
                    await myDevice.ReadAsync(dataRx, 10);
                }
            }, WorkItemPriority.Normal);
        }
示例#2
0
 public DeviceNode(IFTDeviceInfoNode device)
 {
     DeviceType = device.DeviceType;
     DeviceId = device.DeviceId;
 }
示例#3
0
 public DeviceNode(IFTDeviceInfoNode device)
 {
     DeviceType = device.DeviceType;
     DeviceId   = device.DeviceId;
 }