return SR_OK;
}
-SR_PRIV uint8_t dso_get_capturestate(struct context *ctx)
+SR_PRIV int dso_get_capturestate(struct context *ctx, uint8_t *capturestate,
+ uint32_t *trigger_offset)
{
- int ret, tmp;
+ int ret, tmp, i;
+ unsigned int bitvalue, toff;
uint8_t cmdstring[2], inbuf[512];
sr_dbg("hantek-dso: sending CMD_GET_CAPTURESTATE");
if ((ret = send_bulkcmd(ctx, cmdstring, sizeof(cmdstring))) != SR_OK) {
sr_dbg("Failed to send get_capturestate command: %d", ret);
- return CAPTURE_UNKNOWN;
+ return SR_ERR;
}
if ((ret = libusb_bulk_transfer(ctx->usb->devhdl,
DSO_EP_IN | LIBUSB_ENDPOINT_IN,
inbuf, 512, &tmp, 100)) != 0) {
sr_dbg("Failed to get capturestate: %d", ret);
- return CAPTURE_UNKNOWN;
+ return SR_ERR;
}
+ *capturestate = inbuf[0];
+ toff = (inbuf[1] << 16) | (inbuf[3] << 8) | inbuf[2];
- return inbuf[0];
+ /* This conversion comes from the openhantek project.
+ * Each set bit in the 24-bit value inverts all bits with a lower
+ * value. No idea why the device reports the trigger point this way.
+ */
+ bitvalue = 1;
+ for (i = 0; i < 24; i++) {
+ /* Each set bit inverts all bits with a lower value. */
+ if(toff & bitvalue)
+ toff ^= bitvalue - 1;
+ bitvalue <<= 1;
+ }
+ *trigger_offset = toff;
+
+ return SR_OK;
}
-SR_PRIV uint8_t dso_capture_start(struct context *ctx)
+SR_PRIV int dso_capture_start(struct context *ctx)
{
int ret;
uint8_t cmdstring[2];