X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fcenter-3xx%2Fapi.c;h=8118a2b1f5ef099b49e066fe1ce97cac170079e9;hb=f57d8ffe66612a1fdc20ed09c222f8ea59bd84d4;hp=9a43323da3d8a9f451b7b49e001e20005517c088;hpb=5827f61b641cfd326a9cf2ea534eb4f9481a8187;p=libsigrok.git diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 9a43323d..8118a2b1 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -25,9 +25,12 @@ static const uint32_t scanopts[] = { SR_CONF_SERIALCOMM, }; -static const uint32_t devopts[] = { +static const uint32_t drvopts[] = { SR_CONF_THERMOMETER, - SR_CONF_CONTINUOUS, +}; + +static const uint32_t devopts[] = { + SR_CONF_CONTINUOUS | SR_CONF_SET, SR_CONF_LIMIT_SAMPLES | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_SET, }; @@ -76,7 +79,7 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx) if (!(serial = sr_serial_dev_inst_new(conn, serialcomm))) return NULL; - if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK) + if (serial_open(serial, SERIAL_RDWR) != SR_OK) return NULL; drvc = center_devs[idx].di->priv; @@ -85,18 +88,13 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx) sr_info("Found device on port %s.", conn); - if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, center_devs[idx].vendor, - center_devs[idx].device, NULL))) - goto scan_cleanup; - - if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { - sr_err("Device context malloc failed."); - goto scan_cleanup; - } - + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; + sdi->vendor = g_strdup(center_devs[idx].vendor); + sdi->model = g_strdup(center_devs[idx].device); + devc = g_malloc0(sizeof(struct dev_context)); sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; - sdi->priv = devc; sdi->driver = center_devs[idx].di; @@ -191,7 +189,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - (void)sdi; (void)cg; switch (key) { @@ -200,7 +197,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); break; case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + if (!sdi) + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t)); + else + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; default: