상속: IDisposable
예제 #1
0
 public FTDeviceStream(FTDevice device)
 {
     Device = device;
 }
예제 #2
0
        public void TestBootload()
        {
            using (_device = FTDevice.Open())
            {
                // reset device
                _device.SetBitMode(FTBitMode.CBUSBitBang, 0xF0);
                Thread.Sleep(10);
                _device.SetBitMode(FTBitMode.CBUSBitBang, 0xFF);
                Thread.Sleep(100);

                // empty any possible leftover data in the rx/tx queue
                // this is necessary because the serialtest program is blasting the usart with data
                // and some of it lives on after the reset in the ft queues
                _device.Purge();

                _device.SetFlowControl(FTFlowControl.None);
                _device.SetDataCharacteristics(8, 1, FTParity.None);
                _device.SetBaudRate(19200);

                SendHELO();
                ReceiveEHLO();
                EnterProgrammingMode();
                ParseHEX("serialtest.hex");
                WriteImage();
                VerifyImage();
                LeaveProgrammingMode();

                _device.SetBaudRate(38400);
                _device.WaitFor(FTEvent.RxChar);
                var msg = new byte[10];
                _device.ReadFully(msg, 0, 10);
                var text = Encoding.ASCII.GetString(msg);
                Assert.AreEqual("serialtest", text);
            }
        }