* - ...
*/
-static void decode_packet(struct dev_context *devc, int dmm, const uint8_t *buf)
+static void decode_packet(struct sr_dev_inst *sdi, int dmm, const uint8_t *buf)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
+ struct dev_context *devc;
+ struct fs9721_info info;
float floatval;
int ret;
+ devc = sdi->priv;
memset(&analog, 0, sizeof(struct sr_datafeed_analog));
/* Parse the protocol packet. */
+ ret = SR_ERR;
if (dmm == UNI_T_UT61D)
ret = sr_dmm_parse_fs9922(buf, &floatval, &analog);
else if (dmm == VOLTCRAFT_VC820)
- ret = sr_dmm_parse_fs9721(buf, &floatval, &analog);
+ ret = sr_fs9721_parse(buf, &floatval, &analog, &info);
if (ret != SR_OK) {
sr_err("Invalid DMM packet, ignoring.");
return;
}
/* Send a sample packet with one analog value. */
+ analog.probes = sdi->probes;
analog.num_samples = 1;
analog.data = &floatval;
packet.type = SR_DF_ANALOG;
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0);
if (ret < 0) {
- sr_err("Failed to detach kernel driver: %d.", ret);
+ sr_err("Failed to detach kernel driver: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Successfully detached kernel driver.");
/* Claim interface 0. */
if ((ret = libusb_claim_interface(devc->usb->devhdl, 0)) < 0) {
- sr_err("Failed to claim interface 0: %d.", ret);
+ sr_err("Failed to claim interface 0: %s.",
+ libusb_error_name(ret));
return SR_ERR;
}
sr_dbg("Successfully claimed interface 0.");
1000 /* timeout (ms) */);
if (ret < 0) {
- sr_err("HID feature report error: %d.", ret);
+ sr_err("HID feature report error: %s.", libusb_error_name(ret));
return SR_ERR;
}
1000 /* timeout (ms) */);
if (ret < 0) {
- sr_err("USB receive error: %d.", ret);
+ sr_err("USB receive error: %s.", libusb_error_name(ret));
return FALSE;
}
return TRUE;
} else if (dmm == VOLTCRAFT_VC820) {
/* Valid packets have 0x1 as high nibble. */
- if ((buf[1] & 0xf0) != 0x10)
+ if (!sr_fs9721_is_packet_start(buf[1]))
return TRUE;
}
synced_on_first_packet = TRUE;
if (data_byte_counter == NUM_DATA_BYTES) {
log_dmm_packet(pbuf);
data_byte_counter = 0;
- decode_packet(devc, dmm, pbuf);
+ if (dmm == VOLTCRAFT_VC820) {
+ if (!sr_fs9721_packet_valid(pbuf)) {
+ sr_err("Invalid packet.");
+ return TRUE;
+ }
+ }
+ decode_packet(sdi, dmm, pbuf);
memset(pbuf, 0x00, NUM_DATA_BYTES);
}
}
/* Abort acquisition if we acquired enough samples. */
- if (devc->num_samples >= devc->limit_samples && devc->limit_samples > 0) {
+ if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
sdi->driver->dev_acquisition_stop(sdi, cb_data);
}