]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/tondaj-sl-814/api.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / tondaj-sl-814 / api.c
index 32f5de7bcc353b1f017798f6d26caca89dcd0501..bc6fa18e1bbd1987e8eee7ef01d33594d7935709 100644 (file)
@@ -31,8 +31,11 @@ static const uint32_t scanopts[] = {
        SR_CONF_SERIALCOMM,
 };
 
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
        SR_CONF_SOUNDLEVELMETER,
+};
+
+static const uint32_t devopts[] = {
        SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
        SR_CONF_LIMIT_MSEC | SR_CONF_SET,
@@ -79,8 +82,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        serial = sr_serial_dev_inst_new(conn, serialcomm);
 
-       if (serial_open(serial, SERIAL_RDWR) != SR_OK)
+       if (serial_open(serial, SERIAL_RDWR) != SR_OK) {
+               g_free(sdi);
                return NULL;
+       }
 
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
@@ -91,41 +96,22 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, g_slist_append(NULL, sdi));
 }
 
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
        (void)cg;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        return sr_sw_limits_config_set(&devc->limits, key, data);
 }
 
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+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) {
-       case SR_CONF_SCAN_OPTIONS:
-               *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_UINT32,
-                               devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
-               break;
-       default:
-               return SR_ERR_NA;
-       }
-
-       return SR_OK;
+       return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
@@ -133,14 +119,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        struct dev_context *devc = sdi->priv;
        struct sr_serial_dev_inst *serial;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        std_session_send_df_header(sdi);
-       
+
        sr_sw_limits_acquisition_start(&devc->limits);
 
-       /* Poll every 500ms, or whenever some data comes in. */
        serial = sdi->conn;
        serial_source_add(sdi->session, serial, G_IO_IN, 500,
                      tondaj_sl_814_receive_data, (void *)sdi);
@@ -156,7 +138,7 @@ static struct sr_dev_driver tondaj_sl_814_driver_info = {
        .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = std_dev_list,
-       .dev_clear = NULL,
+       .dev_clear = std_dev_clear,
        .config_get = NULL,
        .config_set = config_set,
        .config_list = config_list,