/*
* This file is part of the sigrok project.
*
- * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
if ((err = libusb_get_device_descriptor(dev, des))) {
- sr_warn("failed to get device descriptor: %d", err);
+ sr_err("failed to get device descriptor: %d", err);
return -1;
}
}
if (zp->num_channels == 0) {
- sr_warn("Unknown ZeroPlus device %04X", des->idProduct);
+ sr_err("Unknown ZeroPlus device %04X", des->idProduct);
return -2;
}
(*sdi)->index, zp->usb->bus,
zp->usb->address, USB_INTERFACE);
} else {
- sr_warn("failed to open device: %d", err);
+ sr_err("failed to open device: %d", err);
*sdi = NULL;
}
}
// memset(zp->trigger_buffer, 0, NUM_TRIGGER_STAGES);
if (libusb_init(&usb_context) != 0) {
- sr_warn("Failed to initialize USB.");
+ sr_err("Failed to initialize USB.");
return 0;
}
for (i = 0; devlist[i]; i++) {
err = libusb_get_device_descriptor(devlist[i], &des);
if (err != 0) {
- sr_warn("failed to get device descriptor: %d", err);
+ sr_err("failed to get device descriptor: %d", err);
continue;
}
int err;
if (!(sdi = zp_open_device(device_index))) {
- sr_warn("unable to open device");
+ sr_err("unable to open device");
return SR_ERR;
}
err = libusb_set_configuration(zp->usb->devhdl, USB_CONFIGURATION);
if (err < 0) {
- sr_warn("zp: Unable to set USB configuration %d: %d",
- USB_CONFIGURATION, err);
+ sr_err("zp: Unable to set USB configuration %d: %d",
+ USB_CONFIGURATION, err);
return SR_ERR;
}
err = libusb_claim_interface(zp->usb->devhdl, USB_INTERFACE);
if (err != 0) {
- sr_warn("Unable to claim interface: %d", err);
+ sr_err("Unable to claim interface: %d", err);
return SR_ERR;
}
return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
GSList *l;
+ /* TODO: Error handling. */
+
/* Properly close all devices... */
for (l = device_instances; l; l = l->next)
close_device((struct sr_device_instance *)l->data);
if (usb_context)
libusb_exit(usb_context);
usb_context = NULL;
+
+ return SR_OK;
}
static void *hw_get_device_info(int device_index, int device_info_id)
}
/* This stops acquisition on ALL devices, ignoring device_index. */
-static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int device_index, gpointer session_device_id)
{
struct sr_datafeed_packet packet;
struct sr_device_instance *sdi;
if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
sr_err("zp: %s: sdi was NULL", __func__);
- return; /* FIXME */
+ return SR_ERR_BUG;
}
if (!(zp = sdi->priv)) {
sr_err("zp: %s: sdi->priv was NULL", __func__);
- return; /* FIXME */
+ return SR_ERR_BUG;
}
analyzer_reset(zp->usb->devhdl);
/* TODO: Need to cancel and free any queued up transfers. */
+
+ return SR_OK;
}
SR_PRIV struct sr_device_plugin zeroplus_logic_cube_plugin_info = {