return NULL;
if (bus > 64) {
- sr_err("invalid bus");
+ sr_err("Invalid bus.");
return NULL;
}
if (addr > 127) {
- sr_err("invalid address");
+ sr_err("Invalid address.");
return NULL;
}
libusb_get_device_list(genericdmm_usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("genericdmm: failed to get device descriptor: %d", err);
+ sr_err("Failed to get device descriptor: %d.", err);
continue;
}
/* Found one. */
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("genericdmm: devc malloc failed.");
+ sr_err("Device context malloc failed.");
return 0;
}
devcnt = g_slist_length(drvc->instances);
if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE,
NULL, NULL, NULL))) {
- sr_err("genericdmm: sr_dev_inst_new returned NULL.");
+ sr_err("sr_dev_inst_new returned NULL.");
return NULL;
}
sdi->priv = devc;
devices = NULL;
/* TODO */
- sr_dbg("not yet implemented");
+ sr_dbg("Not yet implemented.");
return devices;
}
cnt = libusb_get_device_list(genericdmm_usb_context, &devlist);
if (cnt < 0) {
- sr_err("genericdmm: Failed to retrieve device list (%d)", cnt);
+ sr_err("Failed to retrieve device list (%d).", cnt);
return SR_ERR;
}
ret = SR_ERR;
for (i = 0; i < cnt; i++) {
if ((tmp = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("genericdmm: Failed to get device descriptor: %d.", tmp);
+ sr_err("Failed to get device descriptor: %d.", tmp);
continue;
}
continue;
if ((tmp = libusb_open(devlist[i], &devc->usb->devhdl))) {
- sr_err("genericdmm: Failed to open device: %d.", tmp);
+ sr_err("Failed to open device: %d.", tmp);
break;
}
- sr_info("genericdmm: Opened device %s on %d.%d ", devc->profile->modelid,
- devc->usb->bus, devc->usb->address);
+ sr_info("Opened device %s on %d.%d.", devc->profile->modelid,
+ devc->usb->bus, devc->usb->address);
ret = SR_OK;
break;
}
for (l = drvc->instances; l; l = l->next) {
if (!(sdi = l->data)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("genericdmm: sdi was NULL, continuing.");
+ sr_err("sdi was NULL, continuing.");
continue;
}
if (!(devc = sdi->priv)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("genericdmm: sdi->priv was NULL, continuing.");
+ sr_err("sdi->priv was NULL, continuing.");
continue;
}
struct drv_context *drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
- sr_err("genericdmm: driver context malloc failed.");
+ sr_err("Driver context malloc failed.");
return SR_ERR;
}
if (libusb_init(&genericdmm_usb_context) != 0) {
- sr_err("genericdmm: Failed to initialize USB.");
+ sr_err("Failed to initialize USB.");
return SR_ERR;
}
int ret;
if (!(devc = sdi->priv)) {
- sr_err("genericdmm: sdi->priv was NULL.");
+ sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
}
ret = open_usb(sdi);
break;
case DMM_TRANSPORT_SERIAL:
- sr_dbg("genericdmm: Opening serial port '%s'.", devc->serial->port);
+ sr_dbg("Opening serial port '%s'.", devc->serial->port);
devc->serial->fd = serial_open(devc->serial->port, O_RDWR | O_NONBLOCK);
if (devc->serial->fd == -1) {
- sr_err("genericdmm: Couldn't open serial port '%s'.",
+ sr_err("Couldn't open serial port '%s'.",
devc->serial->port);
ret = SR_ERR;
}
struct dev_context *devc;
if (!(devc = sdi->priv)) {
- sr_err("genericdmm: %s: sdi->priv was NULL.", __func__);
+ sr_err("%s: sdi->priv was NULL.", __func__);
return SR_ERR_BUG;
}
struct dev_context *devc;
if (!(devc = sdi->priv)) {
- sr_err("genericdmm: sdi->priv was NULL.");
+ sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
}
case SR_HWCAP_LIMIT_MSEC:
/* TODO: not yet implemented */
if (*(const uint64_t *)value == 0) {
- sr_err("genericdmm: LIMIT_MSEC can't be 0.");
+ sr_err("LIMIT_MSEC can't be 0.");
return SR_ERR;
}
devc->limit_msec = *(const uint64_t *)value;
- sr_dbg("genericdmm: Setting time limit to %" PRIu64 "ms.",
+ 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("genericdmm: Setting sample limit to %" PRIu64 ".",
+ sr_dbg("Setting sample limit to %" PRIu64 ".",
devc->limit_samples);
break;
default:
- sr_err("genericdmm: Unknown capability: %d.", hwcap);
+ sr_err("Unknown capability: %d.", hwcap);
return SR_ERR;
break;
}
struct dev_context *devc;
if (!(devc = sdi->priv)) {
- sr_err("genericdmm: sdi->priv was NULL.");
+ sr_err("sdi->priv was NULL.");
return SR_ERR_BUG;
}
- sr_dbg("genericdmm: Starting acquisition.");
+ sr_dbg("Starting acquisition.");
devc->cb_data = cb_data;
/* Send header packet to the session bus. */
- sr_dbg("genericdmm: Sending SR_DF_HEADER.");
+ sr_dbg("Sending SR_DF_HEADER.");
packet.type = SR_DF_HEADER;
packet.payload = (uint8_t *)&header;
header.feed_version = 1;
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
- sr_dbg("genericdmm: Sending SR_DF_META_ANALOG.");
+ sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
/* Avoid compiler warnings. */
(void)sdi;
- sr_dbg("genericdmm: Stopping acquisition.");
+ sr_dbg("Stopping acquisition.");
/* Send end packet to the session bus. */
- sr_dbg("genericdmm: Sending SR_DF_END.");
+ sr_dbg("Sending SR_DF_END.");
packet.type = SR_DF_END;
sr_session_send(cb_data, &packet);
#include <string.h>
#include <math.h>
-#define DMM_DATA_SIZE 14
+/* Message logging helpers with driver-specific prefix string. */
+#define DRIVER_LOG_DOMAIN "victor-dmm: "
+#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
+#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
+#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
+#define DMM_DATA_SIZE 14
/* Reverse the high nibble into the low nibble */
static uint8_t decode_digit(uint8_t in)
struct sr_datafeed_analog analog;
long factor, ivalue;
uint8_t digits[4];
- gboolean is_duty, is_continuity, is_diode, is_ac, is_dc, is_auto,
- is_hold, is_max, is_min, is_relative, minus;
+ gboolean is_duty, is_continuity, is_diode, is_ac, is_dc, is_auto;
+ gboolean is_hold, is_max, is_min, is_relative, minus;
float fvalue;
digits[0] = decode_digit(data[12]);
factor = 3;
break;
default:
- sr_err("genericdmm/victor-70c: unknown decimal point value %.2x", data[7]);
+ sr_err("Unknown decimal point value %.2x.", data[7]);
}
/* Minus flag */
break;
case 0x80:
/* Never seen */
- sr_dbg("genericdmm/victor-70c: unknown mode right detail %.2x", data[4]);
+ sr_dbg("Unknown mode right detail %.2x.", data[4]);
break;
default:
- sr_dbg("genericdmm/victor-70c: unknown/invalid mode right detail %.2x", data[4]);
+ sr_dbg("Unknown/invalid mode right detail %.2x.", data[4]);
}
/* Scale flags on the right, continued */
analog.mq = SR_MQ_DUTY_CYCLE;
analog.unit = SR_UNIT_PERCENTAGE;
} else
- sr_dbg("genericdmm/victor-70c: 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("genericdmm/victor-70c: unknown measurement mode %.2x", data[3]);
+ sr_dbg("Unknown measurement mode %.2x.", data[3]);
break;
case 0x10:
analog.mq = SR_MQ_FREQUENCY;
analog.unit = SR_UNIT_FAHRENHEIT;
break;
default:
- sr_dbg("genericdmm/victor-70c: unknown/invalid measurement mode %.2x", data[3]);
+ sr_dbg("Unknown/invalid measurement mode %.2x.", data[3]);
}
if (analog.mq == -1)
return;
sr_session_send(devc->cb_data, &packet);
devc->num_samples++;
-
}
static int victor70c_data(struct sr_dev_inst *sdi)
/* First time through. */
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
if (libusb_detach_kernel_driver(devc->usb->devhdl, 0) < 0) {
- sr_err("genericdmm/victor-70c: failed to detach kernel driver");
+ sr_err("Failed to detach kernel driver.");
return SR_ERR;
}
}
if (libusb_claim_interface(devc->usb->devhdl, 0)) {
- sr_err("genericdmm/victor-70c: failed to claim interface 0");
+ sr_err("Failed to claim interface 0.");
return SR_ERR;
}
sdi->status = SR_ST_ACTIVE;
ret = libusb_interrupt_transfer(devc->usb->devhdl, 0x81, buf, DMM_DATA_SIZE,
&len, 100);
if (ret != 0) {
- sr_err("genericdmm/victor-70c: failed to get data: libusb error %d", ret);
+ sr_err("Failed to get data: libusb error %d.", ret);
return SR_ERR;
}
if (len != DMM_DATA_SIZE) {
- sr_dbg("genericdmm/victor-70c: short packet: received %d/%d bytes",
- len, DMM_DATA_SIZE);
+ sr_dbg("Short packet: received %d/%d bytes.",
+ len, DMM_DATA_SIZE);
return SR_ERR;
}
for (i = 0; i < DMM_DATA_SIZE && buf[i] == 0; i++);
if (i == DMM_DATA_SIZE) {
/* This DMM outputs all zeroes from time to time, just ignore it. */
- sr_dbg("genericdmm/victor-70c: received all zeroes");
+ sr_dbg("Received all zeroes.");
return SR_OK;
}
if (sr_log_loglevel_get() >= SR_LOG_SPEW) {
dbg = g_string_sized_new(128);
- g_string_printf(dbg, "genericdmm/victor-70c: deobfuscated");
+ g_string_printf(dbg, "Deobfuscated.");
for (i = 0; i < DMM_DATA_SIZE; i++)
g_string_append_printf(dbg, " %.2x", data[i]);
sr_spew("%s", dbg->str);
return SR_OK;
}
-
SR_PRIV struct dmmchip dmmchip_victor70c = {
.data = victor70c_data,
};
-