コード例 #1
0
ファイル: controller.c プロジェクト: alxlit/rtl-and-liquid
void controller_execute(controller ctrl)
{
  struct timespec time;
  float dt;
  
  char header[2048];
  size_t header_size = 0;
  
  int16_t * data;
  int data_len;
  size_t data_size;
  
  clock_gettime(CLOCK_REALTIME_COARSE, & time);

  // time (secs) since last heartbeat
  dt = (time.tv_sec - ctrl->heartbeat_time.tv_sec);
  dt += (time.tv_nsec - ctrl->heartbeat_time.tv_nsec) / 1e9;

  if (dt >= 0.25f) {
    _controller_create_header(ctrl, header, & header_size);

    // reset sample count
    ctrl->heartbeat_num_samples = 0;
    
    // update time
    ctrl->heartbeat_time.tv_sec = time.tv_sec;
    ctrl->heartbeat_time.tv_nsec = time.tv_nsec;
  }

  // give control to the scanner
  scanner_execute(ctrl->scan, ctrl->dem, ctrl->r);

  // block until new output is available
  demod_pop_and_lock(ctrl->dem, & data, & data_len);
  
  data_size = data_len * sizeof(int16_t);

  // send to client
  websocket_send(ctrl->ws, header, header_size, data, data_size);

  demod_release(ctrl->dem);

  // keep count
  ctrl->heartbeat_num_samples += data_len;
}
コード例 #2
0
/* example of creating all the demod-structure and tuner-structures and tuning them in diversity and start monitoring after that */
int main(int argc, char *argv[])
{
    struct dibI2CAdapter *main_i2c = open_spp_i2c();
    struct dibI2CAdapter *tuner_i2c[2];
    struct dibDemod *demod[2];
    struct dibTuner *tuner[2];

    struct dibDemodMonitor mon[2];

    struct dibDVBChannel ch;

    DibZeroMemory(mon, sizeof(mon));

    if (main_i2c == NULL)
        return 1;

    if (dib7000m_attach(main_i2c, 2, DEFAULT_DIB7000M_I2C_ADDRESS, 1, dib7000m_demod_config, demod) != 0) {
        DibDbgPrint("-E-  dib7000 attaching and i2c enumeration failed.\n");
        exit(1);
    }

    tuner_i2c[0] = dib7000m_get_i2c_master(demod[0], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[0] = env57h12d5_attach(tuner_i2c[0], &tuner_0_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -0- attaching failed.\n");
        exit(1);
    }

    tuner_i2c[1] = dib7000m_get_i2c_master(demod[1], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[1] = env57h12d5_attach(tuner_i2c[1], &tuner_1_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -1- attaching failed.\n");
        exit(1);
    }

    INIT_DVB_CHANNEL(&ch);
    ch.RF_kHz = 474000;
    ch.Bw     = INDEX_BW_8_0_MHZ;

    tune_diversity_tuner_and_demod(tuner,demod,2,&ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        demod_get_monitoring(demod[0], &mon[0]);
        demod_get_monitoring(demod[1], &mon[1]);
        dib7000_print_monitor(mon, NULL, 0, 2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    tuner_release(tuner[1]);
    tuner_release(tuner[0]);

    demod_release(demod[1]);
    demod_release(demod[0]);

    close_spp_i2c();

    return 0;
}
コード例 #3
0
/* example of creating all the demod-structure and tuner-structures and tuning them in diversity and start monitoring after that */
int main(int argc, char *argv[])
{
    struct dibI2CAdapter *main_i2c = open_spp_i2c();
    struct dibI2CAdapter *tuner_i2c[2];
    struct dibDemod *demod[2];
    struct dibTuner *tuner[2];

    struct dibDemodMonitor mon[2];

    struct dibDVBChannel ch;

    DibZeroMemory(mon, sizeof(mon));

    if (main_i2c == NULL)
        return 1;

    /* attach 2 demods, do i2c-enumeration */
    if (dib7000p_attach(main_i2c, 2, DEFAULT_DIB7000P_I2C_ADDRESS, 1, dib7000p_example_board_config, demod) != 0) {
        DibDbgPrint("-E-  dib7000 attaching and i2c enumeration failed.\n");
        exit(1);
    }

    /* first tuner */
    tuner_i2c[0] = dib7000p_get_i2c_master(demod[0], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[0] = env57h12d5_attach(tuner_i2c[0], &tuner_0_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -0- attaching failed.\n");
        exit(1);
    }

    /* second tuner */
    tuner_i2c[1] = dib7000p_get_i2c_master(demod[1], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[1] = env57h12d5_attach(tuner_i2c[1], &tuner_1_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -1- attaching failed.\n");
        exit(1);
    }

    INIT_DVB_CHANNEL(&ch);
    ch.RF_kHz = 474000;
    ch.Bw     = INDEX_BW_8_0_MHZ;

    /* tune the 2 demods and tuner to the channel "ch" */
    tune_diversity_tuner_and_demod(tuner,demod,2,&ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        /* get monitoring information for the first demod */
        demod_get_monitoring(demod[0], &mon[0]);
        /* get monitoring information for the second demod */
        demod_get_monitoring(demod[1], &mon[1]);
        /* display information for 2 demods */
        dib7000_print_monitor(mon, NULL, 0, 2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    /* release the 2 tuners */
    tuner_release(tuner[1]);
    tuner_release(tuner[0]);

    /* release the 2 demods */
    demod_release(demod[1]);
    demod_release(demod[0]);

    close_spp_i2c();

    return 0;
}
コード例 #4
0
void frontend_unregister_demod(struct dibFrontend *fe)
{
    demod_release(fe); fe->demod_info = fe->demod_priv = NULL;
}