(void)fd;
(void)revents;
+ /* Get the current position. */
+ sigma_read_pos(&ctx->state.stoppos, &ctx->state.triggerpos, ctx);
+
numchunks = (ctx->state.stoppos + 511) / 512;
if (ctx->state.state == SIGMA_IDLE)
- return FALSE;
+ return TRUE;
if (ctx->state.state == SIGMA_CAPTURE) {
/* Check if the timer has expired, or memory is full. */
(tv.tv_usec - ctx->start_tv.tv_usec) / 1000;
if (running_msec < ctx->limit_msec && numchunks < 32767)
- return FALSE;
+ return TRUE; /* While capturing... */
+ else {
hw_dev_acquisition_stop(sdi->index, sdi);
- return FALSE;
} else if (ctx->state.state == SIGMA_DOWNLOAD) {
if (ctx->state.chunks_downloaded >= numchunks) {
/* End of samples. */
{
struct sr_dev_inst *sdi;
struct context *ctx;
- struct sr_datafeed_packet packet;
- struct sr_datafeed_header header;
+ struct sr_datafeed_packet *packet;
+ struct sr_datafeed_header *header;
struct clockselect_50 clockselect;
int frac, triggerpin, ret;
uint8_t triggerselect;
ctx->session_dev_id = cb_data;
- /* Send header packet to the session bus. */
- packet.type = SR_DF_HEADER;
- packet.payload = &header;
- header.feed_version = 1;
- gettimeofday(&header.starttime, NULL);
- header.samplerate = ctx->cur_samplerate;
- header.num_logic_probes = ctx->num_probes;
- sr_session_send(ctx->session_dev_id, &packet);
+ if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
+ sr_err("sigma: %s: packet malloc failed.", __func__);
+ return SR_ERR_MALLOC;
+ }
+
+ if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
+ sr_err("sigma: %s: header malloc failed.", __func__);
+ return SR_ERR_MALLOC;
+ }
/* Add capture source. */
sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
+ /* Send header packet to the session bus. */
+ packet->type = SR_DF_HEADER;
+ packet->payload = header;
+ header->feed_version = 1;
+ gettimeofday(&header->starttime, NULL);
+ header->samplerate = ctx->cur_samplerate;
+ header->num_logic_probes = ctx->num_probes;
+ sr_session_send(ctx->session_dev_id, packet);
+ g_free(header);
+ g_free(packet);
+
ctx->state.state = SIGMA_CAPTURE;
return SR_OK;