*/
#include <glib.h>
-#include "libsigrok.h"
-#include "libsigrok-internal.h"
-#include "protocol.h"
#include <libusb.h>
#include <stdlib.h>
#include <string.h>
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
+#include "protocol.h"
#define VICTOR_VID 0x1244
#define VICTOR_PID 0xd237
"P1",
};
-
/* Properly close and free all devices. */
static int clear_instances(void)
{
continue;
devcnt = g_slist_length(drvc->instances);
- if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE, VICTOR_VENDOR,
- NULL, NULL)))
+ if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE,
+ VICTOR_VENDOR, NULL, NULL)))
return NULL;
sdi->driver = di;
|| libusb_get_device_address(devlist[i]) != devc->usb->address)
continue;
if ((ret = libusb_open(devlist[i], &devc->usb->devhdl))) {
- sr_err("Failed to open device: %s", libusb_error_name(ret));
+ sr_err("Failed to open device: %s.", libusb_error_name(ret));
return SR_ERR;
}
break;
if ((ret = libusb_claim_interface(devc->usb->devhdl,
VICTOR_INTERFACE))) {
- sr_err("Failed to claim interface: %s", libusb_error_name(ret));
+ sr_err("Failed to claim interface: %s.", libusb_error_name(ret));
return SR_ERR;
}
sdi->status = SR_ST_ACTIVE;
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
{
-
(void)sdi;
switch (info_id) {
- case SR_DI_HWCAPS:
- *data = hwcaps;
- break;
- case SR_DI_NUM_PROBES:
- *data = GINT_TO_POINTER(1);
- break;
- case SR_DI_PROBE_NAMES:
- *data = probe_names;
- break;
- default:
- return SR_ERR_ARG;
+ case SR_DI_HWCAPS:
+ *data = hwcaps;
+ break;
+ case SR_DI_NUM_PROBES:
+ *data = GINT_TO_POINTER(1);
+ break;
+ case SR_DI_PROBE_NAMES:
+ *data = probe_names;
+ break;
+ default:
+ sr_err("Unknown info_id: %d.", info_id);
+ return SR_ERR_ARG;
}
return SR_OK;
devc = sdi->priv;
ret = SR_OK;
switch (hwcap) {
- case SR_HWCAP_LIMIT_MSEC:
- devc->limit_msec = *(const int64_t *)value;
- now = g_get_monotonic_time() / 1000;
- devc->end_time = now + devc->limit_msec;
- sr_dbg("setting time limit to %" PRIu64 "ms.",
- devc->limit_msec);
- break;
- case SR_HWCAP_LIMIT_SAMPLES:
- devc->limit_samples = *(const uint64_t *)value;
- sr_dbg("setting sample limit to %" PRIu64 ".",
- devc->limit_samples);
- break;
+ case SR_HWCAP_LIMIT_MSEC:
+ devc->limit_msec = *(const int64_t *)value;
+ now = g_get_monotonic_time() / 1000;
+ devc->end_time = now + devc->limit_msec;
+ sr_dbg("Setting time limit to %" PRIu64 "ms.",
+ devc->limit_msec);
+ break;
+ case SR_HWCAP_LIMIT_SAMPLES:
+ devc->limit_samples = *(const uint64_t *)value;
+ sr_dbg("Setting sample limit to %" PRIu64 ".",
+ devc->limit_samples);
+ break;
default:
sr_err("Unknown hardware capability: %d.", hwcap);
ret = SR_ERR_ARG;
/* USB device was unplugged. */
hw_dev_acquisition_stop(sdi, sdi);
} else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
- sr_dbg("got %d-byte packet", transfer->actual_length);
+ sr_dbg("Got %d-byte packet.", transfer->actual_length);
if (transfer->actual_length == DMM_DATA_SIZE) {
victor_dmm_receive_data(sdi, transfer->buffer);
if (devc->limit_samples) {
if (sdi->status == SR_ST_ACTIVE) {
/* Send the same request again. */
if ((ret = libusb_submit_transfer(transfer) != 0)) {
- sr_err("unable to resubmit transfer: %s", libusb_error_name(ret));
+ sr_err("Unable to resubmit transfer: %s.",
+ libusb_error_name(ret));
libusb_free_transfer(transfer);
g_free(transfer->buffer);
hw_dev_acquisition_stop(sdi, sdi);
libusb_free_transfer(transfer);
g_free(transfer->buffer);
}
-
}
static int handle_events(int fd, int revents, void *cb_data)
* times you ask, but we want to keep step with the USB events
* handling above. */
libusb_fill_interrupt_transfer(transfer, devc->usb->devhdl,
- VICTOR_ENDPOINT, buf, DMM_DATA_SIZE, receive_transfer, cb_data, 100);
+ VICTOR_ENDPOINT, buf, DMM_DATA_SIZE, receive_transfer,
+ cb_data, 100);
if ((ret = libusb_submit_transfer(transfer) != 0)) {
- sr_err("unable to submit transfer: %s", libusb_error_name(ret));
+ sr_err("Unable to submit transfer: %s.", libusb_error_name(ret));
libusb_free_transfer(transfer);
g_free(buf);
return SR_ERR;
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
-
(void)cb_data;
if (!di->priv) {
*/
#include <glib.h>
+#include <string.h>
+#include <math.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "protocol.h"
-#include <string.h>
-#include <math.h>
-
/* Reverse the high nibble into the low nibble */
static uint8_t decode_digit(uint8_t in)
factor = 3;
break;
default:
- sr_err("Unknown decimal point value %.2x.", data[7]);
+ sr_err("Unknown decimal point byte: 0x%.2x.", data[7]);
+ break;
}
/* Minus flag */
break;
case 0x80:
/* Never seen */
- sr_dbg("Unknown mode right detail %.2x.", data[4]);
+ sr_dbg("Unknown mode right detail: 0x%.2x.", data[4]);
break;
default:
- sr_dbg("Unknown/invalid mode right detail %.2x.", data[4]);
+ sr_dbg("Unknown/invalid mode right detail: 0x%.2x.", data[4]);
+ break;
}
/* Scale flags on the right, continued */
analog.mq = SR_MQ_DUTY_CYCLE;
analog.unit = SR_UNIT_PERCENTAGE;
} else
- sr_dbg("Unknown measurement mode %.2x.", data[3]);
+ sr_dbg("Unknown measurement mode: %.2x.", data[3]);
break;
case 0x01:
if (is_diode) {
break;
case 0x08:
/* Never seen */
- sr_dbg("Unknown measurement mode %.2x.", data[3]);
+ sr_dbg("Unknown measurement mode: 0x%.2x.", data[3]);
break;
case 0x10:
analog.mq = SR_MQ_FREQUENCY;
analog.unit = SR_UNIT_FAHRENHEIT;
break;
default:
- sr_dbg("Unknown/invalid measurement mode %.2x.", data[3]);
+ sr_dbg("Unknown/invalid measurement mode: 0x%.2x.", data[3]);
+ break;
}
if (analog.mq == -1)
return;
return SR_OK;
}
-