public void TestPingCopter()
        {
            if (crazyradioDrivers != null && crazyradioDrivers.Any())
            {
                // Use the first available Crazyradio USB dongle returned from the scan in the initialize test methods call.
                var crazyradioDriver = crazyradioDrivers.First();

                try
                {
                    // Open the Crazyradio USB dongle device for communication and configuration.
                    crazyradioDriver.Open();

                    // Get Crazyradio USB dongle to scann for communication channels of Crazyflie quadcopters.
                    var scanResults = crazyradioDriver.ScanChannels();
                    if (scanResults.Any())
                    {
                        // Pick the first result...
                        var firstScanResult = scanResults.First();

                        // Results are grouped by DataRate...
                        var dataRateWithCrazyflie = firstScanResult.DataRate;
                        // Pick the first communication RadioChannel...
                        var channelWithCrazyflie = firstScanResult.Channels.First();

                        // Set the CrazyradioDriver to use the above communication RadioChannel and DataRate to communicate with the Crazyflie quadcopter using that DataRate and RadioChannel...
                        crazyradioDriver.DataRate = dataRateWithCrazyflie;
                        crazyradioDriver.Channel = channelWithCrazyflie;

                        // Create a ping packet to set to the Crazyflie we're going to ping 10 times.
                        // We can reuse this same ping packet object. No point in creating a new one for each ping.
                        var pingPacket = new PingPacket();

                        // Get ping packet bytes just to print out.
                        var pingPacketBytes = pingPacket.GetBytes();

                        int i = 0;
                        while (i < 10)
                        {
                            // Print out the ping packet bytes.
                            Console.WriteLine("Ping Packet Bytes: {0}", BitConverter.ToString(pingPacketBytes));

                            // Send the ping packet bytes via the CrazyradioDriver and get ACK (acknowledgement) response bytes.
                            var ackResponse = crazyradioDriver.SendData(pingPacketBytes);

                            // Print out the ACK response bytes.
                            Console.WriteLine("ACK Response Bytes (using driver): {0}", BitConverter.ToString(ackResponse));

                            // one more time!
                            i++;
                        }
                    }
                    else
                    {
                        throw new Exception("No Crazyflie Quadcopters found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error testing Crazyradio.", ex);
                }
                finally
                {
                    // Close the Crazyradio USB dongle for communication.
                    crazyradioDriver.Close();
                }
            }
            else
            {
                throw new Exception("No Crazyradio USB dongles found!");
            }

            Assert.IsTrue(true);
        }
Пример #2
0
        private static void Main(string[] args)
        {
            SetUpLogging();

            IEnumerable <ICrazyradioDriver> crazyradioDrivers = null;

            try
            {
                Log.Debug("Starting Crazyradio USB dongle tests.");

                crazyradioDrivers = CrazyradioDriver.GetCrazyradios();
            }
            catch (Exception ex)
            {
                Log.Error("Error getting Crazyradios.", ex);
            }

            if (crazyradioDrivers != null && crazyradioDrivers.Any())
            {
                var crazyradioDriver = crazyradioDrivers.First();

                try
                {
                    crazyradioDriver.Open();

                    var scanResults = crazyradioDriver.ScanChannels();
                    if (scanResults.Any())
                    {
                        var firstScanResult = scanResults.First();

                        var dataRateWithCrazyflie = firstScanResult.DataRate;
                        var channelWithCrazyflie  = firstScanResult.Channels.First();

                        crazyradioDriver.DataRate = dataRateWithCrazyflie;
                        crazyradioDriver.Channel  = channelWithCrazyflie;

                        var pingPacket      = new PingPacket();
                        var pingPacketBytes = pingPacket.GetBytes();

                        var crazyRadioMessenger = new CrazyradioMessenger(crazyradioDriver);

                        var loop = true;
                        while (loop)
                        {
                            // test 2 (using CTRP lib)
                            {
                                Log.InfoFormat("Ping Packet Bytes: {0}", BitConverter.ToString(pingPacketBytes));

                                var ackPacket      = crazyRadioMessenger.SendMessage(new PingPacket());
                                var ackPacketBytes = ackPacket.GetBytes();

                                Log.InfoFormat("ACK Response Bytes (using CTRP): {0}", BitConverter.ToString(ackPacketBytes));
                            }

                            if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Spacebar)
                            {
                                loop = false;
                            }
                        }
                    }
                    else
                    {
                        Log.Warn("No Crazyflie Quadcopters found!");
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Error testing Crazyradio.", ex);
                }
                finally
                {
                    crazyradioDriver.Close();
                }
            }
            else
            {
                Log.Warn("No Crazyradio USB dongles found!");
            }

            Log.Info("Sleepy time...Hit space to exit.");

            var sleep = true;

            while (sleep)
            {
                if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Spacebar)
                {
                    sleep = false;
                }
            }
        }
Пример #3
0
        public void TestPingCopter()
        {
            if (crazyradioDrivers != null && crazyradioDrivers.Any())
            {
                // Use the first available Crazyradio USB dongle returned from the scan in the initialize test methods call.
                var crazyradioDriver = crazyradioDrivers.First();

                try
                {
                    // Open the Crazyradio USB dongle device for communication and configuration.
                    crazyradioDriver.Open();

                    // Get Crazyradio USB dongle to scann for communication channels of Crazyflie quadcopters.
                    var scanResults = crazyradioDriver.ScanChannels();
                    if (scanResults.Any())
                    {
                        // Pick the first result...
                        var firstScanResult = scanResults.First();

                        // Results are grouped by DataRate...
                        var dataRateWithCrazyflie = firstScanResult.DataRate;
                        // Pick the first communication RadioChannel...
                        var channelWithCrazyflie = firstScanResult.Channels.First();

                        // Set the CrazyradioDriver to use the above communication RadioChannel and DataRate to communicate with the Crazyflie quadcopter using that DataRate and RadioChannel...
                        crazyradioDriver.DataRate = dataRateWithCrazyflie;
                        crazyradioDriver.Channel  = channelWithCrazyflie;

                        // Create a ping packet to set to the Crazyflie we're going to ping 10 times.
                        // We can reuse this same ping packet object. No point in creating a new one for each ping.
                        var pingPacket = new PingPacket();

                        // Get ping packet bytes just to print out.
                        var pingPacketBytes = pingPacket.GetBytes();

                        int i = 0;
                        while (i < 10)
                        {
                            // Print out the ping packet bytes.
                            Console.WriteLine("Ping Packet Bytes: {0}", BitConverter.ToString(pingPacketBytes));

                            // Send the ping packet bytes via the CrazyradioDriver and get ACK (acknowledgement) response bytes.
                            var ackResponse = crazyradioDriver.SendData(pingPacketBytes);

                            // Print out the ACK response bytes.
                            Console.WriteLine("ACK Response Bytes (using driver): {0}", BitConverter.ToString(ackResponse));

                            // one more time!
                            i++;
                        }
                    }
                    else
                    {
                        throw new Exception("No Crazyflie Quadcopters found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error testing Crazyradio.", ex);
                }
                finally
                {
                    // Close the Crazyradio USB dongle for communication.
                    crazyradioDriver.Close();
                }
            }
            else
            {
                throw new Exception("No Crazyradio USB dongles found!");
            }

            Assert.IsTrue(true);
        }
Пример #4
0
        private static void Main(string[] args)
        {
            SetUpLogging();

            IEnumerable<ICrazyradioDriver> crazyradioDrivers = null;

            try
            {
                Log.Debug("Starting Crazyradio USB dongle tests.");

                crazyradioDrivers = CrazyradioDriver.GetCrazyradios();
            }
            catch (Exception ex)
            {
                Log.Error("Error getting Crazyradios.", ex);
            }

            if (crazyradioDrivers != null && crazyradioDrivers.Any())
            {
                var crazyradioDriver = crazyradioDrivers.First();

                try
                {
                    crazyradioDriver.Open();

                    var scanResults = crazyradioDriver.ScanChannels();
                    if (scanResults.Any())
                    {
                        var firstScanResult = scanResults.First();

                        var dataRateWithCrazyflie = firstScanResult.DataRate;
                        var channelWithCrazyflie = firstScanResult.Channels.First();

                        crazyradioDriver.DataRate = dataRateWithCrazyflie;
                        crazyradioDriver.Channel = channelWithCrazyflie;

                        var pingPacket = new PingPacket();
                        var pingPacketBytes = pingPacket.GetBytes();

                        var crazyRadioMessenger = new CrazyradioMessenger(crazyradioDriver);

                        var loop = true;
                        while (loop)
                        {
                            // test 2 (using CTRP lib)
                            {
                                Log.InfoFormat("Ping Packet Bytes: {0}", BitConverter.ToString(pingPacketBytes));

                                var ackPacket = crazyRadioMessenger.SendMessage(new PingPacket());
                                var ackPacketBytes = ackPacket.GetBytes();

                                Log.InfoFormat("ACK Response Bytes (using CTRP): {0}", BitConverter.ToString(ackPacketBytes));
                            }

                            if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Spacebar)
                            {
                                loop = false;
                            }
                        }
                    }
                    else
                    {
                        Log.Warn("No Crazyflie Quadcopters found!");
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Error testing Crazyradio.", ex);
                }
                finally
                {
                    crazyradioDriver.Close();
                }
            }
            else
            {
                Log.Warn("No Crazyradio USB dongles found!");
            }

            Log.Info("Sleepy time...Hit space to exit.");

            var sleep = true;
            while (sleep)
            {
                if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Spacebar)
                {
                    sleep = false;
                }
            }
        }