X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fgmc-mh-1x-2x%2Fapi.c;h=96621bbfd6636f8f52a76b36dcdca496f19e99bc;hb=ad9dbc1cdb4818954ee2954787feefc896b4c5c4;hp=6b16c2ec6e1215066c507c7288dd964a25f2ecd9;hpb=a90061e5d1d3f60e4dccd9a408ad53269cc7d7cd;p=libsigrok.git diff --git a/hardware/gmc-mh-1x-2x/api.c b/hardware/gmc-mh-1x-2x/api.c index 6b16c2ec..96621bbf 100644 --- a/hardware/gmc-mh-1x-2x/api.c +++ b/hardware/gmc-mh-1x-2x/api.c @@ -162,7 +162,7 @@ static GSList *scan_1x_2x_rs232(GSList *options) struct drv_context *drvc; struct dev_context *devc; struct sr_config *src; - struct sr_probe *probe; + struct sr_channel *ch; struct sr_serial_dev_inst *serial; GSList *l, *devices; const char *conn, *serialcomm; @@ -224,7 +224,7 @@ static GSList *scan_1x_2x_rs232(GSList *options) if (model != METRAHIT_NONE) { sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(model)); if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, VENDOR_GMC, - gmc_model_str(model), ""))) + gmc_model_str(model), NULL))) return NULL; if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { sr_err("Device context malloc failed."); @@ -240,9 +240,9 @@ static GSList *scan_1x_2x_rs232(GSList *options) sdi->conn = serial; sdi->priv = devc; sdi->driver = &gmc_mh_1x_2x_rs232_driver_info; - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1"))) return NULL; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); } @@ -259,7 +259,7 @@ static GSList *scan_2x_bd232(GSList *options) struct drv_context *drvc; struct dev_context *devc; struct sr_config *src; - struct sr_probe *probe; + struct sr_channel *ch; struct sr_serial_dev_inst *serial; GSList *l, *devices; const char *conn, *serialcomm; @@ -343,9 +343,9 @@ static GSList *scan_2x_bd232(GSList *options) sdi->conn = serial; sdi->priv = devc; sdi->driver = &gmc_mh_2x_bd232_driver_info; - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1"))) goto exit_err; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); @@ -393,16 +393,6 @@ static GSList *dev_list_2x_bd232(void) ->instances; } -static int dev_clear_1x_2x_rs232(void) -{ - return std_dev_clear(&gmc_mh_1x_2x_rs232_driver_info, NULL); -} - -static int dev_clear_2x_bd232(void) -{ - return std_dev_clear(&gmc_mh_2x_bd232_driver_info, NULL); -} - static int dev_close(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -423,29 +413,25 @@ static int dev_close(struct sr_dev_inst *sdi) static int cleanup_sm_rs232(void) { - return dev_clear_1x_2x_rs232(); + return std_dev_clear(&gmc_mh_1x_2x_rs232_driver_info, NULL); } static int cleanup_2x_bd232(void) { - return dev_clear_2x_bd232(); + return std_dev_clear(&gmc_mh_2x_bd232_driver_info, NULL); } /** Get value of configuration item */ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { int ret; struct dev_context *devc; - (void)sdi; - (void)data; - (void)probe_group; + (void)cg; ret = SR_OK; - (void)probe_group; - if (!sdi || !(devc = sdi->priv)) return SR_ERR_ARG; @@ -457,7 +443,6 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_LIMIT_MSEC: *data = g_variant_new_uint64(devc->limit_msec); break; - case SR_CONF_POWER_OFF: *data = g_variant_new_boolean(FALSE); break; @@ -470,10 +455,10 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, /** Implementation of config_list, auxiliary function for common parts, */ static int config_list_common(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { (void)sdi; - (void)probe_group; + (void)cg; switch (key) { case SR_CONF_SCAN_OPTIONS: @@ -489,18 +474,15 @@ static int config_list_common(int key, GVariant **data, const struct sr_dev_inst /** Implementation of config_list for Metrahit 1x/2x send mode */ static int config_list_sm(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { - (void)sdi; - (void)probe_group; - switch (key) { case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, hwcaps_sm, ARRAY_SIZE(hwcaps_sm), sizeof(int32_t)); break; default: - return config_list_common(key, data, sdi, probe_group); + return config_list_common(key, data, sdi, cg); } return SR_OK; @@ -508,18 +490,15 @@ static int config_list_sm(int key, GVariant **data, const struct sr_dev_inst *sd /** Implementation of config_list for Metrahit 2x bidirectional mode */ static int config_list_bd(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { - (void)sdi; - (void)probe_group; - switch (key) { case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, hwcaps_bd, ARRAY_SIZE(hwcaps_bd), sizeof(int32_t)); break; default: - return config_list_common(key, data, sdi, probe_group); + return config_list_common(key, data, sdi, cg); } return SR_OK; @@ -550,8 +529,8 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi, /* Poll every 40ms, or whenever some data comes in. */ serial = sdi->conn; - serial_source_add(serial, G_IO_IN, 40, gmc_mh_1x_2x_receive_data, - (void *)sdi); + serial_source_add(sdi->session, serial, G_IO_IN, 40, + gmc_mh_1x_2x_receive_data, (void *)sdi); return SR_OK; } @@ -581,8 +560,8 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi, /* Poll every 40ms, or whenever some data comes in. */ serial = sdi->conn; - serial_source_add(serial, G_IO_IN, 40, gmc_mh_2x_receive_data, - (void *)sdi); + serial_source_add(sdi->session, serial, G_IO_IN, 40, + gmc_mh_2x_receive_data, (void *)sdi); /* Send start message */ return req_meas14(sdi); @@ -608,7 +587,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = { .cleanup = cleanup_sm_rs232, .scan = scan_1x_2x_rs232, .dev_list = dev_list_1x_2x_rs232, - .dev_clear = dev_clear_1x_2x_rs232, + .dev_clear = NULL, .config_get = config_get, .config_set = config_set, .config_list = config_list_sm, @@ -627,7 +606,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = { .cleanup = cleanup_2x_bd232, .scan = scan_2x_bd232, .dev_list = dev_list_2x_bd232, - .dev_clear = dev_clear_2x_bd232, + .dev_clear = NULL, .config_get = config_get, .config_set = config_set, .config_list = config_list_bd,