]> sigrok.org Git - libsigrok.git/blobdiff - device.c
configure.ac: libserialport is optional.
[libsigrok.git] / device.c
index a49faa8d595df9c05743adb9ec5fbce6b79898e2..55be3254ba42b2e7c5658f03437b3ad1adf8da02 100644 (file)
--- a/device.c
+++ b/device.c
@@ -80,7 +80,7 @@ SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
  *
  * @return SR_OK on success, or SR_ERR_ARG on invalid arguments.
  *
- * @since 0.1.0 (but the API changed in 0.2.0)
+ * @since 0.2.0
  */
 SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi,
                int probenum, const char *name)
@@ -154,7 +154,7 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
  *
  * @return SR_OK on success, or SR_ERR_ARG on invalid arguments.
  *
- * @since 0.1.0 (but the API changed in 0.2.0)
+ * @since 0.2.0
  */
 SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
                const char *trigger)
@@ -196,7 +196,7 @@ SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
  *         FALSE is also returned on invalid input parameters or other
  *         error conditions.
  *
- * @since 0.1.0 (but the API changed in 0.2.0)
+ * @since 0.2.0
  */
 SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
 {
@@ -208,7 +208,8 @@ SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
        if (!sdi || !sdi->driver || !sdi->driver->config_list)
                return FALSE;
 
-       if (sdi->driver->config_list(SR_CONF_DEVICE_OPTIONS, &gvar, NULL) != SR_OK)
+       if (sdi->driver->config_list(SR_CONF_DEVICE_OPTIONS,
+                               &gvar, NULL, NULL) != SR_OK)
                return FALSE;
 
        ret = FALSE;
@@ -243,6 +244,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
        sdi->model = model ? g_strdup(model) : NULL;
        sdi->version = version ? g_strdup(version) : NULL;
        sdi->probes = NULL;
+       sdi->probe_groups = NULL;
        sdi->conn = NULL;
        sdi->priv = NULL;
 
@@ -258,10 +260,11 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
        for (l = sdi->probes; l; l = l->next) {
                probe = l->data;
                g_free(probe->name);
+               g_free(probe->trigger);
                g_free(probe);
        }
+       g_slist_free(sdi->probes);
 
-       g_free(sdi->priv);
        g_free(sdi->vendor);
        g_free(sdi->model);
        g_free(sdi->version);
@@ -291,13 +294,13 @@ SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
 /** @private */
 SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb)
 {
-       (void)usb;
-
-       /* Nothing to do for this device instance type. */
+       g_free(usb);
 }
 
 #endif
 
+#ifdef HAVE_LIBSERIALPORT
+
 /**
  * @private
  *
@@ -345,6 +348,18 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
        g_free(serial);
 }
 
+#endif
+
+/**
+ * Get the list of devices/instances of the specified driver.
+ *
+ * @param driver The driver to use. Must not be NULL.
+ *
+ * @return The list of devices/instances of this driver, or NULL upon errors
+ *         or if the list is empty.
+ *
+ * @since 0.2.0
+ */
 SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
 {
        if (driver && driver->dev_list)
@@ -353,6 +368,15 @@ SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
                return NULL;
 }
 
+/**
+ * Clear all devices/instances of the specified driver.
+ *
+ * @param driver The driver to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
 SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
 {
        if (driver && driver->dev_clear)
@@ -361,6 +385,15 @@ SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
                return SR_OK;
 }
 
+/**
+ * Open the specified device.
+ *
+ * @param sdi Device instance to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
 SR_API int sr_dev_open(struct sr_dev_inst *sdi)
 {
        int ret;
@@ -373,6 +406,15 @@ SR_API int sr_dev_open(struct sr_dev_inst *sdi)
        return ret;
 }
 
+/**
+ * Close the specified device.
+ *
+ * @param sdi Device instance to use. Must not be NULL.
+ *
+ * @return SR_OK upon success, a negative error code upon errors.
+ *
+ * @since 0.2.0
+ */
 SR_API int sr_dev_close(struct sr_dev_inst *sdi)
 {
        int ret;