]> sigrok.org Git - libsigrok.git/blobdiff - hardware/appa-55ii/api.c
build: Portability fixes.
[libsigrok.git] / hardware / appa-55ii / api.c
index af8fdac2e633bf0e1df9b818ff8cb6da938b31a3..de71e338d8f84fd22b7fd3b618ed25a633b2ebcc 100644 (file)
@@ -52,14 +52,18 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_dev_inst *sdi;
-       struct sr_probe *probe;
-       GSList *devices = NULL, *l;
-       const char *conn = NULL, *serialcomm = NULL;
+       struct sr_channel *ch;
+       struct sr_config *src;
+       GSList *devices, *l;
+       const char *conn, *serialcomm;
        uint8_t buf[50];
-       size_t len = sizeof(buf);
+       size_t len;
 
+       len = sizeof(buf);
+       devices = NULL;
+       conn = serialcomm = NULL;
        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);
@@ -87,12 +91,12 @@ static GSList *scan(GSList *options)
 
        /* Let's get a bit of data and see if we can find a packet. */
        if (serial_stream_detect(serial, buf, &len, 25,
-                                appa_55ii_packet_valid, 500, 9600) != SR_OK)
+                       appa_55ii_packet_valid, 500, 9600) != SR_OK)
                goto scan_cleanup;
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "APPA", "55II", "")))
+       if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, "APPA", "55II", NULL)))
                goto scan_cleanup;
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
@@ -107,12 +111,12 @@ static GSList *scan(GSList *options)
        sdi->priv = devc;
        sdi->driver = di;
 
-       if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T1")))
+       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1")))
                goto scan_cleanup;
-       sdi->probes = g_slist_append(sdi->probes, probe);
-       if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "T2")))
+       sdi->channels = g_slist_append(sdi->channels, ch);
+       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2")))
                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);
@@ -128,22 +132,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 cleanup(void)
 {
-       return dev_clear();
+       return std_dev_clear(di, NULL);
 }
 
 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)
 {
        struct dev_context *devc = sdi->priv;
 
-       (void)probe_group;
+       (void)cg;
 
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
@@ -163,11 +162,13 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
 }
 
 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;
+       const char *tmp_str;
+       unsigned int i;
 
-       (void)probe_group;
+       (void)cg;
 
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
@@ -187,9 +188,8 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                sr_dbg("Setting time limit to %" PRIu64 "ms.", devc->limit_msec);
                break;
        case SR_CONF_DATA_SOURCE: {
-               const char *tmp_str = g_variant_get_string(data, NULL);
-               unsigned int i;
-               for (i=0; i<ARRAY_SIZE(data_sources); i++)
+               tmp_str = g_variant_get_string(data, NULL);
+               for (i = 0; i < ARRAY_SIZE(data_sources); i++)
                        if (!strcmp(tmp_str, data_sources[i])) {
                                devc->data_source = i;
                                break;
@@ -206,10 +206,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:
@@ -231,11 +231,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi,
-                                 void *cb_data)
+               void *cb_data)
 {
-       struct sr_serial_dev_inst *serial = sdi->conn;
+       struct sr_serial_dev_inst *serial;
        struct dev_context *devc;
 
+       serial = sdi->conn;
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
@@ -258,15 +259,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
        /* Poll every 50ms, or whenever some data comes in. */
-       serial_source_add(serial, G_IO_IN, 50, appa_55ii_receive_data, (void *)sdi);
+       serial_source_add(sdi->session, serial, G_IO_IN, 50,
+                       appa_55ii_receive_data, (void *)sdi);
 
        return SR_OK;
 }
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
-       return std_serial_dev_acquisition_stop(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 appa_55ii_driver_info = {
@@ -277,7 +279,7 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
        .cleanup = cleanup,
        .scan = scan,
        .dev_list = dev_list,
-       .dev_clear = dev_clear,
+       .dev_clear = NULL,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,
@@ -285,4 +287,5 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
        .dev_close = std_serial_dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
+       .priv = NULL,
 };