]> sigrok.org Git - libsigrok.git/blobdiff - hardware/chronovu-la/api.c
build: Portability fixes.
[libsigrok.git] / hardware / chronovu-la / api.c
index 292da5a4d3d8729ad4a27fe7edf6a95e356e4713..5a8a3d36c959a1c4b06c7411a07e01508d6907fe 100644 (file)
@@ -26,10 +26,18 @@ static struct sr_dev_driver *di = &chronovu_la_driver_info;
 static const int32_t hwcaps[] = {
        SR_CONF_LOGIC_ANALYZER,
        SR_CONF_SAMPLERATE,
+       SR_CONF_TRIGGER_MATCH,
        SR_CONF_LIMIT_MSEC, /* TODO: Not yet implemented. */
        SR_CONF_LIMIT_SAMPLES, /* TODO: Not yet implemented. */
 };
 
+static const int32_t trigger_matches[] = {
+       SR_TRIGGER_ZERO,
+       SR_TRIGGER_ONE,
+       SR_TRIGGER_RISING,
+       SR_TRIGGER_FALLING,
+};
+
 /* The ChronoVu LA8/LA16 can have multiple VID/PID pairs. */
 static struct {
        uint16_t vid;
@@ -167,8 +175,12 @@ static GSList *scan(GSList *options)
        for (i = 0; i < ARRAY_SIZE(vid_pid); i++) {
                ret = ftdi_usb_open_desc(ftdic, vid_pid[i].vid,
                        vid_pid[i].pid, vid_pid[i].iproduct, NULL);
+               /* Show errors other than "device not found". */
+               if (ret < 0 && ret != -3)
+                       sr_dbg("Error finding/opening device (%d): %s.",
+                              ret, ftdi_get_error_string(ftdic));
                if (ret < 0)
-                       continue; /* No device found. */
+                       continue; /* No device found, or not usable. */
 
                sr_dbg("Found %s device (%04x:%04x).",
                       vid_pid[i].iproduct, vid_pid[i].vid, vid_pid[i].pid);
@@ -364,10 +376,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
                        grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES / 2);
                *data = g_variant_new_tuple(grange, 2);
                break;
-       case SR_CONF_TRIGGER_TYPE:
+       case SR_CONF_TRIGGER_MATCH:
                if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof)
                        return SR_ERR_BUG;
-               *data = g_variant_new_string(devc->prof->trigger_type);
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+                               trigger_matches, devc->prof->num_trigger_matches,
+                               sizeof(int32_t));
                break;
        default:
                return SR_ERR_NA;
@@ -456,8 +470,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                return SR_ERR;
        }
 
-       if (cv_configure_channels(sdi) != SR_OK) {
-               sr_err("Failed to configure channels.");
+       if (cv_convert_trigger(sdi) != SR_OK) {
+               sr_err("Failed to configure trigger.");
                return SR_ERR;
        }
 
@@ -493,7 +507,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        devc->cb_data = cb_data;
 
        /* Send header packet to the session bus. */
-       std_session_send_df_header(cb_data, LOG_PREFIX);
+       std_session_send_df_header(sdi, LOG_PREFIX);
 
        /* Time when we should be done (for detecting trigger timeouts). */
        devc->done = (devc->divcount + 1) * devc->prof->trigger_constant +
@@ -502,7 +516,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        devc->trigger_found = 0;
 
        /* Hook up a dummy handler to receive data from the device. */
-       sr_source_add(-1, G_IO_IN, 0, receive_data, (void *)sdi);
+       sr_session_source_add(sdi->session, -1, G_IO_IN, 0, receive_data, (void *)sdi);
 
        return SR_OK;
 }
@@ -511,15 +525,15 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct sr_datafeed_packet packet;
 
-       (void)sdi;
+       (void)cb_data;
 
        sr_dbg("Stopping acquisition.");
-       sr_source_remove(-1);
+       sr_session_source_remove(sdi->session, -1);
 
        /* Send end packet to the session bus. */
        sr_dbg("Sending SR_DF_END.");
        packet.type = SR_DF_END;
-       sr_session_send(cb_data, &packet);
+       sr_session_send(sdi, &packet);
 
        return SR_OK;
 }