struct sr_datafeed_packet packet;
struct timeval tv;
struct context *ctx;
- int capturestate;
+ uint32_t trigger_offset;
+ uint8_t capturestate;
/* Avoid compiler warnings. */
(void)fd;
if (ctx->dev_state != CAPTURE)
return TRUE;
- if ((capturestate = dso_get_capturestate(ctx)) == CAPTURE_UNKNOWN) {
- /* Generated by the function, not the hardware. */
+ if ((dso_get_capturestate(ctx, &capturestate, &trigger_offset)) != SR_OK)
return TRUE;
- }
sr_dbg("hantek-dso: capturestate %d", capturestate);
+ sr_dbg("hantek-dso: trigger offset 0x%.6x", trigger_offset);
switch (capturestate) {
case CAPTURE_EMPTY:
if (++ctx->capture_empty_count >= MAX_CAPTURE_EMPTY) {
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;
uint8_t cmdstring[2], inbuf[512];
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];
+ *trigger_offset = (inbuf[1] << 16) | (inbuf[3] << 8) | inbuf[2];
- return inbuf[0];
+ 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];
SR_PRIV int dso_enable_trigger(struct context *ctx);
SR_PRIV int dso_force_trigger(struct context *ctx);
SR_PRIV int dso_init(struct context *ctx);
-SR_PRIV uint8_t dso_get_capturestate(struct context *ctx);
-SR_PRIV uint8_t dso_capture_start(struct context *ctx);
+SR_PRIV int dso_get_capturestate(struct context *ctx, uint8_t *capturestate,
+ uint32_t *trigger_offset);
+SR_PRIV int dso_capture_start(struct context *ctx);
SR_PRIV int dso_get_channeldata(struct context *ctx, libusb_transfer_cb_fn cb);
#endif