private void SetDataRate(RadioDataRate dataRate)
        {
            try
            {
                Log.DebugFormat("Setting Crazyradio USB dongle DataRate to {0}.", dataRate);

                ControlTransferOut(CrazyradioRequest.SetDataRate, (short)dataRate, 0, 0, new byte[0]);

                Log.DebugFormat("Successfully set Crazyradio USB dongle DataRate to {0}.", dataRate);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed setting Crazyradio USB dongle data rate to {0}.", dataRate);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
        private ScanChannelsResult ScanChannelsUsingDataRate(RadioDataRate dataRate, RadioChannel channelStart, RadioChannel channelStop)
        {
            var results = new List <RadioChannel>();

            DataRate = dataRate;

            if (FirmwareVersion.CompareTo(MinimumCrazyradioFastFirmwareChannelScanFirmware) >= 0)
            {
                StartRadioScanningChannels(channelStart, channelStop);
                results.AddRange(GetRadioChannelScanningResults());
            }
            else             // slow pc level channel scan
            {
                results.AddRange(ManuallyScanForChannels(channelStart, channelStop));
            }

            return(new ScanChannelsResult(dataRate, results));
        }
예제 #3
0
        public ScanChannelsResult ScanChannels(RadioDataRate dataRate, RadioChannel channelStart = RadioChannel.Channel0, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStart > channelStop)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            var channelBackup  = Channel;
            var dataRateBackup = DataRate;

            Log.DebugFormat("About to scan channels for data rate in channel range. StartChannel: {0}, StopChannel: {1}, DataRate: {2}.", channelStart, channelStop);

            var result = ScanChannelsUsingDataRate(dataRate, channelStart, channelStop);

            Log.DebugFormat("Results of scanning channels for data rate in range. Found: {0}. StartChannel: {1}, StopChannel: {2}, DataRate: {3}.", result.Channels.Count(), channelStart, channelStop, dataRate);
            Log.Debug("Reverting data rate and channel to original values.");

            Channel  = channelBackup;
            DataRate = dataRateBackup;

            return(result);
        }
 /// <summary>
 /// Initializes a scan channel result object containing the DataRate and RadioChannels available for communication with Crazyflie quadcopters.
 /// </summary>
 /// <param name="dataRate">The DataRate of which to use for transmission.</param>
 /// <param name="channels">Collection of RadioChannels available to use for transmission with Crazyflie quadcopters..</param>
 public ScanChannelsResult(RadioDataRate dataRate, IEnumerable<RadioChannel> channels)
 {
     DataRate = dataRate;
     Channels = channels;
 }
예제 #5
0
 /// <summary>
 /// Initializes a scan channel result object containing the DataRate and RadioChannels available for communication with Crazyflie quadcopters.
 /// </summary>
 /// <param name="dataRate">The DataRate of which to use for transmission.</param>
 /// <param name="channels">Collection of RadioChannels available to use for transmission with Crazyflie quadcopters..</param>
 public ScanChannelsResult(RadioDataRate dataRate, IEnumerable <RadioChannel> channels)
 {
     DataRate = dataRate;
     Channels = channels;
 }
        private void SetDataRate(RadioDataRate dataRate)
        {
            try
            {
                Log.DebugFormat("Setting Crazyradio USB dongle DataRate to {0}.", dataRate);

                ControlTransferOut(CrazyradioRequest.SetDataRate, (short) dataRate, 0, 0, new byte[0]);

                Log.DebugFormat("Successfully set Crazyradio USB dongle DataRate to {0}.", dataRate);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed setting Crazyradio USB dongle data rate to {0}.", dataRate);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
        private ScanChannelsResult ScanChannelsUsingDataRate(RadioDataRate dataRate, RadioChannel channelStart, RadioChannel channelStop)
        {
            var results = new List<RadioChannel>();

            DataRate = dataRate;

            if (FirmwareVersion.CompareTo(MinimumCrazyradioFastFirmwareChannelScanFirmware) >= 0)
            {
                StartRadioScanningChannels(channelStart, channelStop);
                results.AddRange(GetRadioChannelScanningResults());
            }
            else // slow pc level channel scan
            {
                results.AddRange(ManuallyScanForChannels(channelStart, channelStop));
            }

            return new ScanChannelsResult(dataRate, results);
        }
        public ScanChannelsResult ScanChannels(RadioDataRate dataRate, RadioChannel channelStart = RadioChannel.Channel1, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStart < channelStop)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            var channelBackup = Channel;
            var dataRateBackup = DataRate;

            Log.DebugFormat("About to scan channels for data rate in channel range. StartChannel: {0}, StopChannel: {1}, DataRate: {2}.", channelStart, channelStop);

            var result = ScanChannelsUsingDataRate(dataRate, channelStart, channelStop);

            Log.DebugFormat("Results of scanning channels for data rate in range. Found: {0}. StartChannel: {1}, StopChannel: {2}, DataRate: {3}.", result.Channels.Count(), channelStart, channelStop, dataRate);
            Log.Debug("Reverting data rate and channel to original values.");

            Channel = channelBackup;
            DataRate = dataRateBackup;

            return result;
        }