X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fteleinfo%2Fapi.c;h=13465f5612f85e72add8093a8e04d5f1f9cca053;hb=8249889dfa871a45d57a6f513d4a1a5751673558;hp=6089f3a5a918ac46b4cb65ac05de60f087772641;hpb=c368e6f3d248a73d69cd0c2c4a7c88a92def55e3;p=libsigrok.git diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 6089f3a5..13465f56 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -36,20 +36,18 @@ static const uint32_t devopts[] = { }; SR_PRIV struct sr_dev_driver teleinfo_driver_info; -static struct sr_dev_driver *di = &teleinfo_driver_info; -static int init(struct sr_context *sr_ctx) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *scan(GSList *options) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct drv_context *drvc; struct dev_context *devc; struct sr_serial_dev_inst *serial; struct sr_dev_inst *sdi; - struct sr_channel *ch; GSList *devices = NULL, *l; const char *conn = NULL, *serialcomm = NULL; uint8_t buf[292]; @@ -74,8 +72,8 @@ static GSList *scan(GSList *options) if (!serialcomm) serialcomm = "1200/7e1"; - if (!(serial = sr_serial_dev_inst_new(conn, serialcomm))) - return NULL; + serial = sr_serial_dev_inst_new(conn, serialcomm); + if (serial_open(serial, SERIAL_RDONLY) != SR_OK) return NULL; @@ -103,42 +101,27 @@ static GSList *scan(GSList *options) sdi->priv = devc; sdi->driver = di; - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P"); if (devc->optarif == OPTARIF_BASE) { - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "BASE"); } else if (devc->optarif == OPTARIF_HC) { - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HP"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HC"); } else if (devc->optarif == OPTARIF_EJP) { - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HN"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPM"); } else if (devc->optarif == OPTARIF_BBR) { - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW"); - sdi->channels = g_slist_append(sdi->channels, ch); - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJB"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJW"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJR"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJB"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJW"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJR"); } - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST"); - sdi->channels = g_slist_append(sdi->channels, ch); - - ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP"); - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "IINST"); + sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "PAPP"); drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); @@ -149,12 +132,12 @@ scan_cleanup: return devices; } -static GSList *dev_list(void) +static GSList *dev_list(const struct sr_dev_driver *di) { return ((struct drv_context *)(di->priv))->instances; } -static int cleanup(void) +static int cleanup(const struct sr_dev_driver *di) { return std_dev_clear(di, NULL); } @@ -177,11 +160,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd switch (key) { case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); - sr_dbg("Setting sample limit to %" PRIu64 ".", devc->limit_samples); break; case SR_CONF_LIMIT_MSEC: devc->limit_msec = g_variant_get_uint64(data); - sr_dbg("Setting time limit to %" PRIu64 "ms.", devc->limit_msec); break; default: return SR_ERR_NA;