#include <ftdi.h>
#include <glib.h>
#include <string.h>
-#include <sigrok.h>
-#include <sigrok-internal.h>
+#include "sigrok.h"
+#include "sigrok-internal.h"
#define USB_VENDOR_ID 0x0403
#define USB_PRODUCT_ID 0x6001
static GSList *device_instances = NULL;
+static const char *probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ NULL,
+};
+
struct la8 {
/** FTDI device context (used by libftdi). */
struct ftdi_context *ftdic;
sr_spew("la8: entering %s", __func__);
/* Avoid compiler errors. */
- deviceinfo = deviceinfo;
+ (void)deviceinfo;
/* Allocate memory for our private driver context. */
if (!(la8 = g_try_malloc(sizeof(struct la8)))) {
sr_err("la8: %s: struct la8 malloc failed", __func__);
- ret = SR_ERR_MALLOC;
goto err_free_nothing;
}
/* Allocate memory where we'll store the de-mangled data. */
if (!(la8->final_buf = g_try_malloc(SDRAM_SIZE))) {
sr_err("la8: %s: final_buf malloc failed", __func__);
- ret = SR_ERR_MALLOC;
goto err_free_la8;
}
/* Allocate memory for the FTDI context (ftdic) and initialize it. */
if (!(la8->ftdic = ftdi_new())) {
sr_err("la8: %s: ftdi_new failed", __func__);
- ret = SR_ERR; /* TODO: More specific error? */
goto err_free_final_buf;
}
/* Check for the device and temporarily open it. */
if ((ret = ftdi_usb_open_desc(la8->ftdic, USB_VENDOR_ID,
USB_PRODUCT_ID, USB_DESCRIPTION, NULL)) < 0) {
- sr_err("la8: %s: ftdi_usb_open_desc: (%d) %s",
+ sr_dbg("la8: %s: ftdi_usb_open_desc: (%d) %s",
__func__, ret, ftdi_get_error_string(la8->ftdic));
(void) la8_close_usb_reset_sequencer(la8); /* Ignore errors. */
- ret = SR_ERR; /* TODO: More specific error? */
goto err_free_ftdic;
}
sr_dbg("la8: found device");
USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
if (!sdi) {
sr_err("la8: %s: sr_device_instance_new failed", __func__);
- ret = SR_ERR; /* TODO: More specific error? */
goto err_close_ftdic;
}
/* Close device. We'll reopen it again when we need it. */
(void) la8_close(la8); /* Log, but ignore errors. */
- // return SR_OK; /* TODO */
return 1;
err_close_ftdic:
err_free_la8:
g_free(la8);
err_free_nothing:
- // return ret; /* TODO */
+
return 0;
}
sr_warn("la8: %s: sdi was NULL, continuing", __func__);
continue;
}
+#if 0
+ /*
+ * Fixes a segfault as it's free()d elsewhere already.
+ * TODO: Document who is supposed to free this, and when.
+ */
if (sdi->priv != NULL)
free(sdi->priv);
else
sr_warn("la8: %s: sdi->priv was NULL, nothing "
"to do", __func__);
+#endif
sr_device_instance_free(sdi); /* Returns void. */
}
g_slist_free(device_instances); /* Returns void. */
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
fill_supported_samplerates_if_needed();
info = &samplerates;
struct la8 *la8;
/* Avoid compiler errors. */
- fd = fd;
- revents = revents;
+ (void)fd;
+ (void)revents;
if (!(sdi = session_data)) {
- sr_err("la8: %s: user_data was NULL", __func__);
+ sr_err("la8: %s: session_data was NULL", __func__);
return FALSE;
}