X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fhardware%2Fgmc-mh-1x-2x%2Fapi.c;h=7443f487eed26440f45503cb9b7c64eb35756ad4;hp=8bac10f14c7cc10e48a9f3cf580512af3646fbf8;hb=05199c0ac9f15f229d43e50e86c4c1eadc55deac;hpb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 8bac10f1..7443f487 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -40,10 +40,13 @@ static const uint32_t scanopts[] = { SR_CONF_SERIALCOMM, }; -/** Hardware capabilities for Metrahit 1x/2x devices in send mode. */ -static const uint32_t devopts_sm[] = { +static const uint32_t drvopts[] = { SR_CONF_MULTIMETER, SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */ +}; + +/** Hardware capabilities for Metrahit 1x/2x devices in send mode. */ +static const uint32_t devopts_sm[] = { SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, @@ -51,8 +54,6 @@ static const uint32_t devopts_sm[] = { /** Hardware capabilities for Metrahit 2x devices in bidirectional Mode. */ static const uint32_t devopts_bd[] = { - SR_CONF_MULTIMETER, - SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */ SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, @@ -159,8 +160,6 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options) conn = serialcomm = NULL; serialcomm_given = FALSE; - sr_spew("scan_1x_2x_rs232() called!"); - for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -242,8 +241,6 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) conn = serialcomm = NULL; devices = NULL; - sr_spew("scan_2x_bd232() called!"); - for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -321,8 +318,6 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); exit_err: - sr_info("scan_2x_bd232(): Error!"); - sr_serial_dev_inst_free(serial); g_free(devc); sr_dev_inst_free(sdi); @@ -344,7 +339,6 @@ static int dev_close(struct sr_dev_inst *sdi) static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - int ret; struct dev_context *devc; (void)cg; @@ -354,7 +348,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s devc = sdi->priv; - ret = SR_OK; switch (key) { case SR_CONF_LIMIT_SAMPLES: case SR_CONF_LIMIT_MSEC: @@ -366,25 +359,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_ERR_NA; } - return ret; -} - -/** Implementation of config_list, auxiliary function for common parts. */ -static int config_list_common(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; - default: - return SR_ERR_NA; - } - return SR_OK; } @@ -392,32 +366,14 @@ static int config_list_common(uint32_t key, GVariant **data, const struct sr_dev static int config_list_sm(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - switch (key) { - case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - devopts_sm, ARRAY_SIZE(devopts_sm), sizeof(uint32_t)); - break; - default: - return config_list_common(key, data, sdi, cg); - } - - return SR_OK; + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts_sm); } /** Implementation of config_list for Metrahit 2x bidirectional mode */ static int config_list_bd(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - switch (key) { - case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - devopts_bd, ARRAY_SIZE(devopts_bd), sizeof(uint32_t)); - break; - default: - return config_list_common(key, data, sdi, cg); - } - - return SR_OK; + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts_bd); } static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi) @@ -469,7 +425,7 @@ static struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = { .cleanup = std_cleanup, .scan = scan_1x_2x_rs232, .dev_list = std_dev_list, - .dev_clear = NULL, + .dev_clear = std_dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list_sm, @@ -489,7 +445,7 @@ static struct sr_dev_driver gmc_mh_2x_bd232_driver_info = { .cleanup = std_cleanup, .scan = scan_2x_bd232, .dev_list = std_dev_list, - .dev_clear = NULL, + .dev_clear = std_dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list_bd,