X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Ftondaj-sl-814%2Fapi.c;h=ca57aaa5b9980ebf3ea69d0d24d375bbd6a9c196;hb=ed20a42803c8b4e79b259ae03298dec88f2299f5;hp=e282f4c7a4836c3787aff814164d1421d2176453;hpb=6fab7b8f5365c7be69be4a755910945b6113dd8f;p=libsigrok.git diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index e282f4c7..ca57aaa5 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -26,17 +26,15 @@ #define SERIALCOMM "9600/8e1" -static const int hwopts[] = { +static const int32_t hwopts[] = { SR_CONF_CONN, SR_CONF_SERIALCOMM, - 0, }; -static const int hwcaps[] = { +static const int32_t hwcaps[] = { SR_CONF_SOUNDLEVELMETER, SR_CONF_LIMIT_SAMPLES, SR_CONF_CONTINUOUS, - 0, }; SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info; @@ -96,10 +94,10 @@ static GSList *hw_scan(GSList *options) } switch (src->key) { case SR_CONF_CONN: - conn = src->value; + conn = g_variant_get_string(src->data, NULL); break; case SR_CONF_SERIALCOMM: - serialcomm = src->value; + serialcomm = g_variant_get_string(src->data, NULL); break; default: sr_err("Unknown option %d, skipping.", src->key); @@ -182,7 +180,7 @@ static int hw_cleanup(void) return SR_OK; } -static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) +static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -195,7 +193,7 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) switch (id) { case SR_CONF_LIMIT_SAMPLES: - devc->limit_samples = *(const uint64_t *)value; + devc->limit_samples = g_variant_get_uint64(data); sr_dbg("Setting sample limit to %" PRIu64 ".", devc->limit_samples); break; @@ -207,17 +205,19 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_list(int key, const void **data, const struct sr_dev_inst *sdi) +static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) { (void)sdi; switch (key) { case SR_CONF_SCAN_OPTIONS: - *data = hwopts; + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, + hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t)); break; case SR_CONF_DEVICE_OPTIONS: - *data = hwcaps; + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, + hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: return SR_ERR_ARG; @@ -246,35 +246,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { - int ret, final_ret; - struct sr_datafeed_packet packet; - struct dev_context *devc; - - final_ret = SR_OK; - - if (sdi->status != SR_ST_ACTIVE) { - sr_err("Device inactive, can't stop acquisition."); - return SR_ERR; - } - - devc = sdi->priv; - - if ((ret = sr_source_remove(devc->serial->fd)) < 0) { - sr_err("Error removing source: %d.", ret); - final_ret = SR_ERR; - } - - if ((ret = hw_dev_close(sdi)) < 0) { - sr_err("Error closing device: %d.", ret); - final_ret = SR_ERR; - } - - /* Send end packet to the session bus. */ - sr_dbg("Sending SR_DF_END."); - packet.type = SR_DF_END; - sr_session_send(cb_data, &packet); - - return final_ret; + return std_hw_dev_acquisition_stop_serial(sdi, cb_data, hw_dev_close, + ((struct dev_context *)(sdi->priv))->serial, DRIVER_LOG_DOMAIN); } SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {