Exemple #1
0
        public void WriteData(int addr, byte[] data, int offset, int count)
        {
            SetAddress(addr);

            var prelude  = new byte[] { (byte)'d', 0, 0, 0 };
            var lenbytes = BitConverter.GetBytes((ushort)count);

            prelude[1] = lenbytes[1];
            prelude[2] = lenbytes[0];
            _device.WriteFully(prelude, 0, 4);
            _device.WriteFully(data, offset, count);
            _device.WriteFully(new[] { (byte)' ' }, 0, 1);
            ReceiveNothing();
        }
Exemple #2
0
        public void TestResetWriteRead()
        {
            using (FTDevice dev = FTDevice.Open(0))
            {
                // reset
                dev.SetBitMode(FTBitMode.CBUSBitBang, 0xF0);
                Thread.Sleep(10);
                dev.SetBitMode(FTBitMode.CBUSBitBang, 0xFF);
                // allow some time for startup
                Thread.Sleep(100);

                // send hello to bootloader
                dev.SetBaudRate(19200);
                var data = new[] { (byte)'1', (byte)' ' };
                dev.WriteFully(data, 0, 2);

                // read ehlo
                var buf = new byte[9];
                int r   = dev.ReadFully(buf, 0, 9);
                Assert.AreEqual(9, r);
                var text = Encoding.ASCII.GetString(buf);
                Assert.IsTrue(text.Contains("AVR ISP"));
            }
        }