X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhwdriver.c;h=5790e320564fc5d8017d17f601f1be6581b4ea56;hb=8141a0325c2d31a37ecaeef6532d932112700f01;hp=0700276cb84db77f39ebdd0ee6e88ca5be9d89c7;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git diff --git a/src/hwdriver.c b/src/hwdriver.c index 0700276c..5790e320 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -17,13 +17,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include #include -#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ #include #include "libsigrok-internal.h" @@ -167,18 +167,12 @@ static struct sr_key_info sr_key_info_config[] = { "Output frequency target", NULL}, {SR_CONF_MEASURED_QUANTITY, SR_T_MQ, "measured_quantity", "Measured quantity", NULL}, - {SR_CONF_MEASURED_2ND_QUANTITY, SR_T_STRING, "measured_2nd_quantity", - "Measured secondary quantity", NULL}, {SR_CONF_EQUIV_CIRCUIT_MODEL, SR_T_STRING, "equiv_circuit_model", "Equivalent circuit model", NULL}, {SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE, SR_T_BOOL, "otp_active", "Over-temperature protection active", NULL}, /* Special stuff */ - {SR_CONF_SCAN_OPTIONS, SR_T_STRING, "scan_options", - "Scan options", NULL}, - {SR_CONF_DEVICE_OPTIONS, SR_T_STRING, "device_options", - "Device options", NULL}, {SR_CONF_SESSIONFILE, SR_T_STRING, "sessionfile", "Session file", NULL}, {SR_CONF_CAPTUREFILE, SR_T_STRING, "capturefile", @@ -208,7 +202,7 @@ static struct sr_key_info sr_key_info_config[] = { {SR_CONF_TEST_MODE, SR_T_STRING, "test_mode", "Test mode", NULL}, - {0, 0, NULL, NULL, NULL}, + ALL_ZERO }; /* Please use the same order as in enum sr_mq (libsigrok.h). */ @@ -394,6 +388,43 @@ SR_API int sr_driver_init(struct sr_context *ctx, struct sr_dev_driver *driver) return ret; } +/** + * Enumerate scan options supported by this driver. + * + * Before calling sr_driver_scan_options_list(), the user must have previously + * initialized the driver by calling sr_driver_init(). + * + * @param driver The driver to enumerate options for. This must be a pointer + * to one of the entries returned by sr_driver_list(). Must not + * be NULL. + * + * @return A GArray * of uint32_t entries, or NULL on invalid arguments. Each + * entry is a configuration key that is supported as a scan option. + * The array must be freed by the caller using g_array_free(). + * + * @since 0.4.0 + */ +SR_API GArray *sr_driver_scan_options_list(const struct sr_dev_driver *driver) +{ + GVariant *gvar; + const uint32_t *opts; + gsize num_opts; + GArray *result; + + if (sr_config_list(driver, NULL, NULL, SR_CONF_SCAN_OPTIONS, &gvar) != SR_OK) + return NULL; + + opts = g_variant_get_fixed_array(gvar, &num_opts, sizeof(uint32_t)); + + result = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t), num_opts); + + g_array_insert_vals(result, 0, opts, num_opts); + + g_variant_unref(gvar); + + return result; +} + static int check_options(struct sr_dev_driver *driver, GSList *options, uint32_t optlist_key, struct sr_dev_inst *sdi, struct sr_channel_group *cg) @@ -571,7 +602,8 @@ static int check_key(const struct sr_dev_driver *driver, GVariant *gvar_opts; const uint32_t *opts; uint32_t pub_opt; - char *suffix, *opstr; + const char *suffix; + const char *opstr; if (sdi && cg) suffix = " for this device and channel group";