X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fconrad-digi-35-cpu%2Fapi.c;h=8a9650ecc8def2841af255f802906bc7bf21055d;hb=0af636bed97c174bea46e61e961eaa1b0b162e0f;hp=01adcef8ab2fec517fb322b0024d5ce5dd991122;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index 01adcef8..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 int32_t hwopts[] = { +static const uint32_t scanopts[] = { SR_CONF_CONN, SR_CONF_SERIALCOMM, }; -static const int32_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, + 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; @@ -121,7 +121,7 @@ static int cleanup(void) return std_dev_clear(di, NULL); } -static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, +static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { int ret; @@ -150,8 +150,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, } ret = send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5)); break; - /* No SR_CONF_OUTPUT_ENABLED :-( . */ - case SR_CONF_OVER_CURRENT_PROTECTION: + case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED: if (g_variant_get_boolean(data)) ret = send_msg1(sdi, 'V', 900); else /* Constant current mode */ @@ -164,7 +163,7 @@ static int config_set(int key, 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(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { int ret; @@ -175,12 +174,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, ret = SR_OK; switch (key) { case SR_CONF_SCAN_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); break; case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; default: return SR_ERR_NA;