X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fconrad-digi-35-cpu%2Fapi.c;h=8a9650ecc8def2841af255f802906bc7bf21055d;hb=0af636bed97c174bea46e61e961eaa1b0b162e0f;hp=a2a881598b1b6b1798faed0d0ce636f8d5100600;hpb=584560f142e1b17b9f4ef9069bd3724f2f77e750;p=libsigrok.git diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index a2a88159..8a9650ec 100644 --- a/src/hardware/conrad-digi-35-cpu/api.c +++ b/src/hardware/conrad-digi-35-cpu/api.c @@ -26,17 +26,16 @@ #define SERIALCOMM "9600/8n1" -static const uint32_t hwopts[] = { +static const uint32_t scanopts[] = { SR_CONF_CONN, SR_CONF_SERIALCOMM, }; -static const uint32_t hwcaps[] = { +static const uint32_t devopts[] = { SR_CONF_POWER_SUPPLY, - SR_CONF_OUTPUT_VOLTAGE, - SR_CONF_OUTPUT_CURRENT, - /* There's no SR_CONF_OUTPUT_ENABLED; can't know/set status remotely. */ - SR_CONF_OVER_CURRENT_PROTECTION_ENABLED, + SR_CONF_OUTPUT_VOLTAGE | SR_CONF_SET, + SR_CONF_OUTPUT_CURRENT | SR_CONF_SET, + SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_SET, }; SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info; @@ -87,7 +86,7 @@ static GSList *scan(GSList *options) 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; serial_flush(serial); @@ -95,9 +94,10 @@ static GSList *scan(GSList *options) sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn); - if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, "Conrad", "DIGI 35 CPU", NULL))) - return NULL; - + sdi = sr_dev_inst_new(); + sdi->status = SR_ST_ACTIVE; + sdi->vendor = g_strdup("Conrad"); + sdi->model = g_strdup("DIGI 35 CPU"); sdi->conn = serial; sdi->priv = NULL; sdi->driver = di; @@ -150,7 +150,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd } ret = send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5)); break; - /* No SR_CONF_OUTPUT_ENABLED :-( . */ case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED: if (g_variant_get_boolean(data)) ret = send_msg1(sdi, 'V', 900); @@ -176,11 +175,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_SCAN_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - hwopts, ARRAY_SIZE(hwopts), sizeof(uint32_t)); + scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); break; case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - hwcaps, ARRAY_SIZE(hwcaps), sizeof(uint32_t)); + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; default: return SR_ERR_NA;