ret = SR_OK;
- /* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
/* Set some sane defaults. */
/* We now know the device, set its max. samplerate as default. */
devc->cur_samplerate = devc->prof->max_samplerate;
- /* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("ChronoVu");
devc = sdi->priv;
- /* Allocate memory for the FTDI context and initialize it. */
if (!(devc->ftdic = ftdi_new())) {
sr_err("Failed to initialize libftdi.");
return SR_ERR;
sr_dbg("Opening %s device (%04x:%04x).", devc->prof->modelname,
devc->usb_vid, devc->usb_pid);
- /* Open the device. */
if ((ret = ftdi_usb_open_desc(devc->ftdic, devc->usb_vid,
devc->usb_pid, devc->prof->iproduct, NULL)) < 0) {
sr_err("Failed to open FTDI device (%d): %s.",
goto err_ftdi_free;
}
- /* Purge RX/TX buffers in the FTDI chip. */
if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_ftdi_free;
}
- /* Enable flow control in the FTDI chip. */
if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) {
sr_err("Failed to enable FTDI flow control (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_ftdi_free;
}
- /* Wait 100ms. */
g_usleep(100 * 1000);
return SR_OK;
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
- GVariant *gvar, *grange[2];
- GVariantBuilder gvb;
+ GVariant *grange[2];
struct dev_context *devc;
devc = (sdi) ? sdi->priv : NULL;
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
case SR_CONF_SAMPLERATE:
cv_fill_samplerates_if_needed(sdi);
- g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
- gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- devc->samplerates,
- ARRAY_SIZE(devc->samplerates),
- sizeof(uint64_t));
- g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
- *data = g_variant_builder_end(&gvb);
+ *data = std_gvar_samplerates(devc->samplerates, ARRAY_SIZE(devc->samplerates));
break;
case SR_CONF_LIMIT_SAMPLES:
if (!devc->prof)