Exemple #1
0
bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir )
{
    RadioModems_t modem;
    int8_t phyDr = DataratesEU433[txConfig->Datarate];
    int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
    uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
    int8_t phyTxPower = 0;

    // Calculate physical TX power
    phyTxPower = RegionCommonComputeTxPower( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );

    // Setup the radio frequency
    Radio.SetChannel( Channels[txConfig->Channel].Frequency );

    if( txConfig->Datarate == DR_7 )
    { // High Speed FSK channel
        modem = MODEM_FSK;
        Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 3000 );
    }
    else
    {
        modem = MODEM_LORA;
        Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
    }
    DBG_PRINTF("TX on freq %d Hz at DR %d\n\r", Channels[txConfig->Channel].Frequency, txConfig->Datarate);
    // Setup maximum payload lenght of the radio driver
    Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
    // Get the time-on-air of the next tx frame
    *txTimeOnAir = Radio.TimeOnAir( modem,  txConfig->PktLen );

    *txPower = txConfig->TxPower;
    return true;
}
Exemple #2
0
bool RegionCN470ATxConfig( TxConfigParams_t *txConfig, int8_t *txPower, TimerTime_t *txTimeOnAir )
{
    RadioModems_t modem;

    uint32_t frequency;
    uint16_t preambleLen;
    bool iqInverted;
    TimerTime_t curTime = TimerGetCurrentTime( );

    int8_t phyDr = DataratesCN470A[txConfig->Datarate];

    int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[TxChannels[txConfig->Channel].Band].TxMaxPower,
                                          txConfig->Datarate, ChannelsMask );
    uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
    int8_t phyTxPower = 0;

    // Calculate physical TX power
    phyTxPower = RegionCommonComputeTxPower( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );

    if (txConfig->NodeWorkMode == NODE_MODE_REPEATER) {
        frequency = txConfig->RepeaterFrequency;
        preambleLen = PreambleLenthCN470A[txConfig->Datarate];
        iqInverted = true;
    } else {
        frequency = TxChannels[txConfig->Channel].Frequency;
        preambleLen = 8;
        iqInverted = false;
    }

    // Setup the radio frequency
    Radio.SetChannel( frequency);

    if ( txConfig->Datarate == DR_7 ) {
        // High Speed FSK channel
        modem = MODEM_FSK;
        Radio.SetTxConfig( modem, phyTxPower, 25e3, bandwidth, phyDr * 1e3, 0, 5, false, true, 0, 0, false, 3e3 );
    } else {
        modem = MODEM_LORA;
        Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, preambleLen, false, true, 0, 0, iqInverted, 3e3 );
    }
    // Setup maximum payload lenght of the radio driver
    Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
    // Get the time-on-air of the next tx frame
    *txTimeOnAir = Radio.TimeOnAir( modem,  txConfig->PktLen );

    *txPower = txConfig->TxPower;

    DBG_LINKWAN("Tx, Band %d, Freq: %d,DR: %d, len: %d, duration %d, at %d\r\n",
                TxFreqBandNum, frequency, txConfig->Datarate, txConfig->PktLen, *txTimeOnAir, curTime);
    return true;
}
Exemple #3
0
void RegionCN470AComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError,
                                            RxConfigParams_t *rxConfigParams )
{
    double tSymbol = 0.0;

    rxConfigParams->Datarate = datarate;
    rxConfigParams->Bandwidth = GetBandwidth( datarate );

    if ( datarate == DR_7 ) {
        // FSK
        tSymbol = RegionCommonComputeSymbolTimeFsk( DataratesCN470A[datarate] );
    } else {
        // LoRa
        tSymbol = RegionCommonComputeSymbolTimeLoRa( DataratesCN470A[datarate], BandwidthsCN470A[datarate] );
    }

    RegionCommonComputeRxWindowParameters( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME,
                                           &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
}
Exemple #4
0
void RegionEU433ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams )
{
    double tSymbol = 0.0;
    uint32_t radioWakeUpTime;

    rxConfigParams->Datarate = datarate;
    rxConfigParams->Bandwidth = GetBandwidth( datarate );

    if( datarate == DR_7 )
    { // FSK
        tSymbol = RegionCommonComputeSymbolTimeFsk( DataratesEU433[datarate] );
    }
    else
    { // LoRa
        tSymbol = RegionCommonComputeSymbolTimeLoRa( DataratesEU433[datarate], BandwidthsEU433[datarate] );
    }

    radioWakeUpTime = Radio.GetRadioWakeUpTime( );
    RegionCommonComputeRxWindowParameters( tSymbol, minRxSymbols, rxError, radioWakeUpTime, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
}
Exemple #5
0
bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir )
{
    int8_t phyDr = DataratesAU915[txConfig->Datarate];
    int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
    uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
    int8_t phyTxPower = 0;

    // Calculate physical TX power
    phyTxPower = RegionCommonComputeTxPower( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );

    Radio.SetChannel( Channels[txConfig->Channel].Frequency );

    Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
    Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
    DBG_PRINTF("TX on freq %d Hz at DR %d\n\r", Channels[txConfig->Channel].Frequency, txConfig->Datarate);

    *txTimeOnAir = Radio.TimeOnAir( MODEM_LORA,  txConfig->PktLen );
    *txPower = txPowerLimited;

    return true;
}
void RegionEU433ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams )
{
    double tSymbol = 0.0;
    uint32_t radioWakeUpTime;

    // Get the datarate, perform a boundary check
    rxConfigParams->Datarate = MIN( datarate, EU433_RX_MAX_DATARATE );
    rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );

    if( rxConfigParams->Datarate == DR_7 )
    { // FSK
        tSymbol = RegionCommonComputeSymbolTimeFsk( DataratesEU433[rxConfigParams->Datarate] );
    }
    else
    { // LoRa
        tSymbol = RegionCommonComputeSymbolTimeLoRa( DataratesEU433[rxConfigParams->Datarate], BandwidthsEU433[rxConfigParams->Datarate] );
    }

    radioWakeUpTime = Radio.GetRadioWakeUpTime( );
    RegionCommonComputeRxWindowParameters( tSymbol, minRxSymbols, rxError, radioWakeUpTime, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
}
Exemple #7
0
int main(int argc, char **argv) {
  auto config = ParseCommandLine(argc, argv);
  printf("%s\n", mila::version::PrintVersion().c_str());

  auto mean_shift_initial =
      mila::meanshift::parallel::MeanShiftImageProcessingProfiler(config.platform_id, config.device_id);
  mean_shift_initial.Run(config.input_file, config.output_file, config.bandwidth);
  auto result = mean_shift_initial.results().at(mean_shift_initial.main_result());
  auto duration = mean_shift_initial.results().at(mean_shift_initial.main_duration());
  printf("Initial results\n");
  printf("%s: %f\n", mean_shift_initial.main_result().c_str(), result);
  printf("Duration [us]: %f\n", duration);
  printf("Platform: %s\n", mean_shift_initial.platform().getName().c_str());
  printf("Device: %s\n", mean_shift_initial.device().getName().c_str());
  printf("Input file: %s\n", config.input_file.c_str());
  printf("Output file: %s\n", config.output_file.c_str());
  printf("Bandwidth: %f\n", config.bandwidth);

  auto results = std::vector<float>(config.number_of_iterations);
  printf("Iterations\n");
  for (size_t i = 0; i < config.number_of_iterations; ++i) {
    auto mean_shift = mila::meanshift::parallel::MeanShiftImageProcessingProfiler(config.platform_id, config.device_id);
    mean_shift.Run(config.input_file, config.output_file, config.bandwidth);
    result = mean_shift.results().at(mean_shift.main_result());
    duration = mean_shift.results().at(mean_shift.main_duration());
    printf("Iteration: %lu\n", i);
    printf("Host statistics:\n");
    printf("Duration: %f us, %s: %f, Bandwidth: %f GB/s\n", duration, mean_shift.main_result().c_str(), result, mean_shift.GetBandwidth());
    printf("OpenCL statistics:\n");
    printf("%s\n", mean_shift.GetOpenCLStatisticsAsString().c_str());
    results[i] = duration;
  }

  printf("Statistics\n");
  printf("Mean: %f\n", mila::utils::Mean(results));
  printf("Median: %f\n", mila::utils::Median(results));
  printf("Variance: %f\n", mila::utils::Variance(results));
  printf("Standard Deviation: %f\n", mila::utils::StandardDeviation(results));
  printf("Coefficient of Variation: %f\n", mila::utils::CoefficientOfVariation(results));

  return 0;
}