* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <glib.h>
#include <libusb.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include "protocol.h"
GSList *usb_devices, *devices, *l;
const char *conn;
- drvc = di->priv;
+ drvc = di->context;
conn = NULL;
for (l = options; l; l = l->next) {
static GSList *dev_list(const struct sr_dev_driver *di)
{
- return ((struct drv_context *)(di->priv))->instances;
+ return ((struct drv_context *)(di->context))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
struct sr_usb_dev_inst *usb;
int ret;
- if (!(drvc = di->priv)) {
+ if (!(drvc = di->context)) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
int ret;
struct drv_context *drvc;
- if (!(drvc = di->priv))
+ if (!(drvc = di->context))
/* Can get called on an unused driver, doesn't matter. */
return SR_OK;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
ret = SR_OK;
switch (key) {
case SR_CONF_DATALOG:
- if (g_variant_get_boolean(data)) {
- /* Start logging. */
+ if (g_variant_get_boolean(data))
ret = lascar_start_logging(sdi);
- } else {
- /* Stop logging. */
+ else
ret = lascar_stop_logging(sdi);
- }
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
- sr_dbg("Setting sample limit to %" PRIu64 ".",
- devc->limit_samples);
break;
default:
ret = SR_ERR_NA;
return SR_OK;
}
-static void mark_xfer(struct libusb_transfer *xfer)
+static void LIBUSB_CALL mark_xfer(struct libusb_transfer *xfer)
{
if (xfer->status == LIBUSB_TRANSFER_COMPLETED)
devc->temp_unit = devc->config[0x2e] | (devc->config[0x2f] << 8);
if (devc->temp_unit != 0 && devc->temp_unit != 1) {
sr_dbg("invalid temperature unit %d", devc->temp_unit);
- /* Default to Celcius, we're all adults here. */
+ /* Default to Celsius, we're all adults here. */
devc->temp_unit = 0;
} else
sr_dbg("temperature unit is %s", devc->temp_unit
- ? "Fahrenheit" : "Celcius");
+ ? "Fahrenheit" : "Celsius");
break;
case LOG_CO:
devc->sample_size = 2;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
- drvc = di->priv;
+ drvc = di->context;
devc = sdi->priv;
usb = sdi->conn;
devc->cb_data = cb_data;
;
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
- resp, sizeof(resp), mark_xfer, 0, 10000);
+ resp, sizeof(resp), mark_xfer, 0, BULK_XFER_TIMEOUT);
if (libusb_submit_transfer(xfer_in) != 0) {
libusb_free_transfer(xfer_in);
libusb_free_transfer(xfer_out);
tv.tv_sec = 0;
tv.tv_usec = 0;
while (!xfer_in->user_data || !xfer_out->user_data) {
- g_usleep(5000);
+ g_usleep(SLEEP_US_LONG);
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
}
if (xfer_in->user_data != GINT_TO_POINTER(1) ||
- xfer_in->user_data != GINT_TO_POINTER(1)) {
+ xfer_out->user_data != GINT_TO_POINTER(1)) {
sr_dbg("no response to log transfer request");
libusb_free_transfer(xfer_in);
libusb_free_transfer(xfer_out);
usb_source_add(sdi->session, drvc->sr_ctx, 100,
lascar_el_usb_handle_events, (void *)sdi);
- buf = g_try_malloc(4096);
+ buf = g_malloc(4096);
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
buf, 4096, lascar_el_usb_receive_transfer, cb_data, 100);
if ((ret = libusb_submit_transfer(xfer_in) != 0)) {
struct sr_dev_driver *di = sdi->driver;
(void)cb_data;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
.dev_close = dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .context = NULL,
};