X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fconrad-digi-35-cpu%2Fapi.c;h=850e29b04c9165733dfca37dcbd075de6afcd8e1;hb=f57d8ffe66612a1fdc20ed09c222f8ea59bd84d4;hp=59ea9c380b7d3fd1a363b94cd506514fb7809c25;hpb=f254bc4bba68d2cade0c8f7993d8fa8d3d9b556a;p=libsigrok.git diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index 59ea9c38..850e29b0 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 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 = g_malloc0(sizeof(struct sr_dev_inst)); + 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,7 +175,7 @@ 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,