X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Frigol-ds1xx2%2Fapi.c;h=ce5d57c57ac1db34cccd30e6de0c2465f56f4381;hb=3d3a601e803d4fe10e2f633b5f0e06104dcf9017;hp=e6e923ccfb7f41f2c78f448e9af1994c8f2a173d;hpb=3b412e3a305cf06ac9bbb91ca5025d1712617b71;p=libsigrok.git diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c index e6e923cc..ce5d57c5 100644 --- a/hardware/rigol-ds1xx2/api.c +++ b/hardware/rigol-ds1xx2/api.c @@ -133,8 +133,10 @@ static const char *coupling[] = { static const char *supported_models[] = { "DS1052E", "DS1102E", + "DS1152E", "DS1052D", "DS1102D", + "DS1152D", }; SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info; @@ -144,7 +146,30 @@ static void clear_helper(void *priv) { struct dev_context *devc; - devc = priv; + for (l = drvc->instances; l; l = l->next) { + if (!(sdi = l->data)) + continue; + + if (sdi->conn) + sr_serial_dev_inst_free(sdi->conn); + + g_slist_free(sdi->probe_groups); + + if (!(devc = sdi->priv)) + continue; + + g_free(devc->device); + g_free(devc->coupling[0]); + g_free(devc->coupling[1]); + g_free(devc->trigger_source); + g_free(devc->trigger_slope); + g_slist_free(devc->analog_groups[0].probes); + g_slist_free(devc->analog_groups[1].probes); + g_slist_free(devc->digital_group.probes); + close(devc->fd); + + sr_dev_inst_free(sdi); + } g_free(devc->coupling[0]); g_free(devc->coupling[1]); @@ -258,10 +283,14 @@ static int probe_port(const char *port, GSList **devices) devc->has_digital = has_digital; for (i = 0; i < 2; i++) { - if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, - i == 0 ? "CH1" : "CH2"))) + channel_name = (i == 0 ? "CH1" : "CH2"); + if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name))) return SR_ERR_MALLOC; sdi->probes = g_slist_append(sdi->probes, probe); + devc->analog_groups[i].name = channel_name; + devc->analog_groups[i].probes = g_slist_append(NULL, probe); + sdi->probe_groups = g_slist_append(sdi->probe_groups, + &devc->analog_groups[i]); } if (devc->has_digital) { @@ -273,6 +302,11 @@ static int probe_port(const char *port, GSList **devices) if (!probe) return SR_ERR_MALLOC; sdi->probes = g_slist_append(sdi->probes, probe); + devc->digital_group.probes = g_slist_append( + devc->digital_group.probes, probe); + devc->digital_group.name = "LA"; + sdi->probe_groups = g_slist_append(sdi->probe_groups, + &devc->digital_group); } } sdi->priv = devc; @@ -307,8 +341,9 @@ static GSList *scan(GSList *options) if (probe_port(port, &devices) == SR_ERR_MALLOC) return NULL; } else { - if (!(dir = g_dir_open("/sys/class/usb/", 0, NULL))) - return NULL; + if (!(dir = g_dir_open("/sys/class/usbmisc/", 0, NULL))) + if (!(dir = g_dir_open("/sys/class/usb/", 0, NULL))) + return NULL; while ((dev_name = g_dir_read_name(dir))) { if (strncmp(dev_name, "usbtmc", 6)) continue; @@ -367,10 +402,12 @@ static int cleanup(void) return dev_clear(); } -static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) +static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { (void)sdi; + (void)probe_group; switch (id) { case SR_CONF_NUM_TIMEBASE: @@ -386,7 +423,8 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) +static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; uint64_t tmp_u64, p, q; @@ -395,6 +433,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) int ret; const char *tmp_str; + (void)probe_group; + devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) @@ -494,13 +534,16 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) return ret; } -static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) +static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { GVariant *tuple, *rational[2]; GVariantBuilder gvb; unsigned int i; struct dev_context *devc; + (void)probe_group; + switch (key) { case SR_CONF_SCAN_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,