X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fteleinfo%2Fapi.c;h=931e5994cd40927bbd490b30a3be3c9d3701b9cd;hb=fd830beb6751a966a0f12a9ca48a8550bbe5bbba;hp=bf70660fc2a4daf6582d04d59222f5189bac1f83;hpb=bf2c987fdef6787a5ce826ed9d98a70f52a1ff96;p=libsigrok.git diff --git a/hardware/teleinfo/api.c b/hardware/teleinfo/api.c index bf70660f..931e5994 100644 --- a/hardware/teleinfo/api.c +++ b/hardware/teleinfo/api.c @@ -49,14 +49,17 @@ static GSList *scan(GSList *options) struct dev_context *devc; struct sr_serial_dev_inst *serial; struct sr_dev_inst *sdi; - struct sr_probe *probe; + struct sr_channel *ch; GSList *devices = NULL, *l; const char *conn = NULL, *serialcomm = NULL; uint8_t buf[292]; - size_t len = sizeof(buf); + size_t len; + struct sr_config *src; + + len = sizeof(buf); for (l = options; l; l = l->next) { - struct sr_config *src = l->data; + src = l->data; switch (src->key) { case SR_CONF_CONN: conn = g_variant_get_string(src->data, NULL); @@ -89,7 +92,7 @@ static GSList *scan(GSList *options) sr_info("Found device on port %s.", conn); - if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "EDF", "Teleinfo", ""))) + if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "EDF", "Teleinfo", NULL))) goto scan_cleanup; if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { @@ -104,56 +107,56 @@ static GSList *scan(GSList *options) sdi->priv = devc; sdi->driver = di; - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); if (devc->optarif == OPTARIF_BASE) { - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "BASE"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } else if (devc->optarif == OPTARIF_HC) { - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HP"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HC"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } else if (devc->optarif == OPTARIF_EJP) { - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HN"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPM"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } else if (devc->optarif == OPTARIF_BBR) { - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJB"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJW"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HPJR"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJB"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJW"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "HCJR"))) + sdi->channels = g_slist_append(sdi->channels, ch); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "IINST"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST"))) goto scan_cleanup; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "PAPP"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP"))) goto scan_cleanup; - 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); @@ -169,34 +172,17 @@ static GSList *dev_list(void) return ((struct drv_context *)(di->priv))->instances; } -static int dev_clear(void) -{ - return std_dev_clear(di, NULL); -} - -static int dev_open(struct sr_dev_inst *sdi) -{ - struct sr_serial_dev_inst *serial = sdi->conn; - - if (serial_open(serial, SERIAL_RDONLY | SERIAL_NONBLOCK) != SR_OK) - return SR_ERR; - - sdi->status = SR_ST_ACTIVE; - - return SR_OK; -} - static int cleanup(void) { - return dev_clear(); + return std_dev_clear(di, NULL); } static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { struct dev_context *devc; - (void)probe_group; + (void)cg; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -223,10 +209,10 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, } static int config_list(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: @@ -278,8 +264,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { - return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close, - sdi->conn, LOG_PREFIX); + return std_serial_dev_acquisition_stop(sdi, cb_data, + std_serial_dev_close, sdi->conn, LOG_PREFIX); } SR_PRIV struct sr_dev_driver teleinfo_driver_info = { @@ -290,11 +276,13 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = { .cleanup = cleanup, .scan = scan, .dev_list = dev_list, - .dev_clear = dev_clear, + .dev_clear = NULL, + .config_get = NULL, .config_set = config_set, .config_list = config_list, - .dev_open = dev_open, + .dev_open = std_serial_dev_open, .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, + .priv = NULL, };