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.
This commit is contained in:
Bert Vermeulen 2012-06-18 23:09:37 +02:00
parent a217bcdf10
commit 6e6eeff47a
3 changed files with 15 additions and 11 deletions

View File

@ -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) {

View File

@ -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 SR_OK;
}
return inbuf[0];
}
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];

View File

@ -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