From: Anatoly Sokolov Date: Sun, 29 Jan 2012 12:56:06 +0000 (+0400) Subject: Add sr_device_get_info X-Git-Tag: libsigrok-0.1.0~160 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fd9836bfab434ed227b685d184e266d3cbc4f6c8;p=libsigrok.git Add sr_device_get_info --- diff --git a/device.c b/device.c index 9b68eb0b..30649cd4 100644 --- a/device.c +++ b/device.c @@ -481,3 +481,32 @@ gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap) return FALSE; } + +/** + * Returns information about the given device. + * + * @param device Pointer to the device to be checked. Must not be NULL. + * The device's 'plugin' field must not be NULL either. + * @param id The type of information. + * @param data The return value. Must not be NULL. + * + * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR + * upon other errors. + */ +int sr_device_get_info(const struct sr_device *device, int id, + const void **data) +{ + if ((device == NULL) || (device->plugin == NULL)) + return SR_ERR_ARG; + + if (data == NULL) + return SR_ERR_ARG; + + *data = device->plugin->get_device_info(device->plugin_index, id); + + if (*data == NULL) + return SR_ERR; + + return SR_OK; +} + diff --git a/sigrok-proto.h b/sigrok-proto.h index e81fad22..80c48948 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -54,6 +54,8 @@ int sr_device_trigger_clear(struct sr_device *device); int sr_device_trigger_set(struct sr_device *device, int probenum, const char *trigger); gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap); +int sr_device_get_info(const struct sr_device *device, int id, + const void **data); /*--- filter.c --------------------------------------------------------------*/