From: Bert Vermeulen Date: Mon, 18 Jun 2012 21:09:37 +0000 (+0200) Subject: hantek-dso: capturestate packet also contains the trigger point X-Git-Tag: dsupstream~914 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6e6eeff47a93e48b31ef5d16feb707e8725dbbd3;p=libsigrok.git hantek-dso: capturestate packet also contains the trigger point Not yet used, but it's the key to knowing where in the frame to start displaying; the frame is used as a circular buffer, and what is sent is effectively a snapshot. --- diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index 1091ea90..e6b87f85 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -628,7 +628,8 @@ static int handle_event(int fd, int revents, void *cb_data) 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; @@ -654,12 +655,11 @@ static int handle_event(int fd, int revents, void *cb_data) 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) { diff --git a/hardware/hantek-dso/dso.c b/hardware/hantek-dso/dso.c index 88158674..1ad30f09 100644 --- a/hardware/hantek-dso/dso.c +++ b/hardware/hantek-dso/dso.c @@ -640,7 +640,8 @@ SR_PRIV int dso_init(struct context *ctx) 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]; @@ -652,20 +653,22 @@ SR_PRIV uint8_t dso_get_capturestate(struct context *ctx) 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]; diff --git a/hardware/hantek-dso/dso.h b/hardware/hantek-dso/dso.h index 3220b90d..ac260147 100644 --- a/hardware/hantek-dso/dso.h +++ b/hardware/hantek-dso/dso.h @@ -203,8 +203,9 @@ SR_PRIV void dso_close(struct sr_dev_inst *sdi); 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