]> sigrok.org Git - libsigrok.git/blobdiff - src/hwdriver.c
Accept subtype of expected GVariant values.
[libsigrok.git] / src / hwdriver.c
index be918e9bfc6ab63543e7f888be3c110bcbd728e3..dc727a5606204fa5c5260bfeba45fcf966ade296 100644 (file)
@@ -106,11 +106,11 @@ static struct sr_config_info sr_config_info_data[] = {
                "Number of analog channels", NULL},
        {SR_CONF_OUTPUT_VOLTAGE, SR_T_FLOAT, "output_voltage",
                "Current output voltage", NULL},
-       {SR_CONF_OUTPUT_VOLTAGE_TARGET, SR_T_FLOAT, "output_voltage_max",
+       {SR_CONF_OUTPUT_VOLTAGE_TARGET, SR_T_FLOAT, "output_voltage_target",
                "Output voltage target", NULL},
        {SR_CONF_OUTPUT_CURRENT, SR_T_FLOAT, "output_current",
                "Current output current", NULL},
-       {SR_CONF_OUTPUT_CURRENT_LIMIT, SR_T_FLOAT, "output_current_max",
+       {SR_CONF_OUTPUT_CURRENT_LIMIT, SR_T_FLOAT, "output_current_limit",
                "Output current limit", NULL},
        {SR_CONF_OUTPUT_ENABLED, SR_T_BOOL, "output_enabled",
                "Output enabled", NULL},
@@ -138,6 +138,14 @@ static struct sr_config_info sr_config_info_data[] = {
                "Over-temperature protection", NULL},
        {SR_CONF_OUTPUT_REGULATION, SR_T_STRING, "output_regulation",
                "Output channel regulation", NULL},
+       {SR_CONF_OUTPUT_FREQUENCY, SR_T_UINT64, "output_frequency",
+               "Output frequency", NULL},
+       {SR_CONF_MEASURED_QUANTITY, SR_T_STRING, "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},
        {0, 0, NULL, NULL, NULL},
 };
 
@@ -170,20 +178,25 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *value)
 {
        const struct sr_config_info *info;
        const GVariantType *type, *expected;
+       char *expected_string, *type_string;
+
        info = sr_config_info_get(key);
        if (!info)
                return SR_OK;
+
        expected = sr_variant_type_get(info->datatype);
        type = g_variant_get_type(value);
-       if (!g_variant_type_equal(type, expected)) {
-               gchar *expected_string = g_variant_type_dup_string(expected);
-               gchar *type_string = g_variant_type_dup_string(type);
+       if (!g_variant_type_equal(type, expected)
+                       && !g_variant_type_is_subtype_of(type, expected)) {
+               expected_string = g_variant_type_dup_string(expected);
+               type_string = g_variant_type_dup_string(type);
                sr_err("Wrong variant type for key '%s': expected '%s', got '%s'",
                        info->name, expected_string, type_string);
                g_free(expected_string);
                g_free(type_string);
                return SR_ERR_ARG;
        }
+
        return SR_OK;
 }