sr: More callback param renames.
Start/stop acquisition callbacks: Consistently name the 'void *' parameter cb_data for now. The per-device-instance device pointer is called 'session_dev_id' everywhere for now, but this should be renamed to something more clear.
This commit is contained in:
parent
1f9813eb6c
commit
3cd3a20b35
|
@ -63,7 +63,7 @@ struct context {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
snd_pcm_t *capture_handle;
|
snd_pcm_t *capture_handle;
|
||||||
snd_pcm_hw_params_t *hw_params;
|
snd_pcm_hw_params_t *hw_params;
|
||||||
gpointer session_id;
|
void *session_dev_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int hw_init(const char *devinfo)
|
static int hw_init(const char *devinfo)
|
||||||
|
@ -293,7 +293,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
@ -368,7 +368,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->session_id = session_dev_id;
|
ctx->session_dev_id = cb_data;
|
||||||
sr_source_add(ufds[0].fd, ufds[0].events, 10, receive_data, sdi);
|
sr_source_add(ufds[0].fd, ufds[0].events, 10, receive_data, sdi);
|
||||||
|
|
||||||
packet.type = SR_DF_HEADER;
|
packet.type = SR_DF_HEADER;
|
||||||
|
@ -380,17 +380,18 @@ static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||||
header.num_analog_probes = NUM_PROBES;
|
header.num_analog_probes = NUM_PROBES;
|
||||||
header.num_logic_probes = 0;
|
header.num_logic_probes = 0;
|
||||||
header.protocol_id = SR_PROTO_RAW;
|
header.protocol_id = SR_PROTO_RAW;
|
||||||
sr_session_send(session_dev_id, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
g_free(ufds);
|
g_free(ufds);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
/* Avoid compiler warnings. */
|
/* Avoid compiler warnings. */
|
||||||
dev_index = dev_index;
|
(void)dev_index;
|
||||||
session_dev_id = session_dev_id;
|
(void)cb_data;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ static const char *firmware_files[] = {
|
||||||
"asix-sigma-phasor.fw", /* Frequency counter */
|
"asix-sigma-phasor.fw", /* Frequency counter */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
|
||||||
|
|
||||||
static int sigma_read(void *buf, size_t size, struct context *ctx)
|
static int sigma_read(void *buf, size_t size, struct context *ctx)
|
||||||
{
|
{
|
||||||
|
@ -879,9 +879,9 @@ static int get_trigger_offset(uint16_t *samples, uint16_t last_sample,
|
||||||
*/
|
*/
|
||||||
static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
uint16_t *lastsample, int triggerpos,
|
uint16_t *lastsample, int triggerpos,
|
||||||
uint16_t limit_chunk, void *session_data)
|
uint16_t limit_chunk, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi = session_data;
|
struct sr_dev_inst *sdi = cb_data;
|
||||||
struct context *ctx = sdi->priv;
|
struct context *ctx = sdi->priv;
|
||||||
uint16_t tsdiff, ts;
|
uint16_t tsdiff, ts;
|
||||||
uint16_t samples[65536 * ctx->samples_per_event];
|
uint16_t samples[65536 * ctx->samples_per_event];
|
||||||
|
@ -935,7 +935,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
logic.length = tosend * sizeof(uint16_t);
|
logic.length = tosend * sizeof(uint16_t);
|
||||||
logic.unitsize = 2;
|
logic.unitsize = 2;
|
||||||
logic.data = samples + sent;
|
logic.data = samples + sent;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
sent += tosend;
|
sent += tosend;
|
||||||
}
|
}
|
||||||
|
@ -978,7 +978,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
logic.length = tosend * sizeof(uint16_t);
|
logic.length = tosend * sizeof(uint16_t);
|
||||||
logic.unitsize = 2;
|
logic.unitsize = 2;
|
||||||
logic.data = samples;
|
logic.data = samples;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
sent += tosend;
|
sent += tosend;
|
||||||
}
|
}
|
||||||
|
@ -986,7 +986,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
/* Only send trigger if explicitly enabled. */
|
/* Only send trigger if explicitly enabled. */
|
||||||
if (ctx->use_triggers) {
|
if (ctx->use_triggers) {
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,7 +999,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
logic.length = tosend * sizeof(uint16_t);
|
logic.length = tosend * sizeof(uint16_t);
|
||||||
logic.unitsize = 2;
|
logic.unitsize = 2;
|
||||||
logic.data = samples + sent;
|
logic.data = samples + sent;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
*lastsample = samples[n - 1];
|
*lastsample = samples[n - 1];
|
||||||
|
@ -1044,7 +1044,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
if (ctx->state.chunks_downloaded >= numchunks) {
|
if (ctx->state.chunks_downloaded >= numchunks) {
|
||||||
/* End of samples. */
|
/* End of samples. */
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
ctx->state.state = SIGMA_IDLE;
|
ctx->state.state = SIGMA_IDLE;
|
||||||
|
|
||||||
|
@ -1254,7 +1254,7 @@ static int build_basic_trigger(struct triggerlut *lut, struct context *ctx)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
@ -1349,7 +1349,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&ctx->start_tv, 0);
|
gettimeofday(&ctx->start_tv, 0);
|
||||||
sigma_set_register(WRITE_MODE, 0x0d, ctx);
|
sigma_set_register(WRITE_MODE, 0x0d, ctx);
|
||||||
|
|
||||||
ctx->session_id = session_data;
|
ctx->session_dev_id = cb_data;
|
||||||
|
|
||||||
/* Send header packet to the session bus. */
|
/* Send header packet to the session bus. */
|
||||||
packet.type = SR_DF_HEADER;
|
packet.type = SR_DF_HEADER;
|
||||||
|
@ -1358,7 +1358,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header.starttime, NULL);
|
gettimeofday(&header.starttime, NULL);
|
||||||
header.samplerate = ctx->cur_samplerate;
|
header.samplerate = ctx->cur_samplerate;
|
||||||
header.num_logic_probes = ctx->num_probes;
|
header.num_logic_probes = ctx->num_probes;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
/* Add capture source. */
|
/* Add capture source. */
|
||||||
sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
|
sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
|
||||||
|
@ -1368,14 +1368,14 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
uint8_t modestatus;
|
uint8_t modestatus;
|
||||||
|
|
||||||
/* Avoid compiler warnings. */
|
/* Avoid compiler warnings. */
|
||||||
(void)session_data;
|
(void)cb_data;
|
||||||
|
|
||||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
|
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
|
||||||
sr_err("sigma: %s: sdi was NULL", __func__);
|
sr_err("sigma: %s: sdi was NULL", __func__);
|
||||||
|
|
|
@ -187,7 +187,7 @@ struct context {
|
||||||
struct sigma_trigger trigger;
|
struct sigma_trigger trigger;
|
||||||
int use_triggers;
|
int use_triggers;
|
||||||
struct sigma_state state;
|
struct sigma_state state;
|
||||||
gpointer session_id;
|
void *session_dev_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,7 +70,7 @@ struct context {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
/** TODO */
|
/** TODO */
|
||||||
gpointer session_id;
|
void *session_dev_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A buffer containing some (mangled) samples from the device.
|
* A buffer containing some (mangled) samples from the device.
|
||||||
|
@ -138,7 +138,7 @@ static int hwcaps[] = {
|
||||||
|
|
||||||
/* Function prototypes. */
|
/* Function prototypes. */
|
||||||
static int la8_close_usb_reset_sequencer(struct context *ctx);
|
static int la8_close_usb_reset_sequencer(struct context *ctx);
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
|
||||||
static int la8_reset(struct context *ctx);
|
static int la8_reset(struct context *ctx);
|
||||||
|
|
||||||
static void fill_supported_samplerates_if_needed(void)
|
static void fill_supported_samplerates_if_needed(void)
|
||||||
|
@ -479,7 +479,7 @@ static int hw_init(const char *devinfo)
|
||||||
ctx->cur_samplerate = SR_MHZ(100); /* 100MHz == max. samplerate */
|
ctx->cur_samplerate = SR_MHZ(100); /* 100MHz == max. samplerate */
|
||||||
ctx->limit_msec = 0;
|
ctx->limit_msec = 0;
|
||||||
ctx->limit_samples = 0;
|
ctx->limit_samples = 0;
|
||||||
ctx->session_id = NULL;
|
ctx->session_dev_id = NULL;
|
||||||
memset(ctx->mangled_buf, 0, BS);
|
memset(ctx->mangled_buf, 0, BS);
|
||||||
ctx->final_buf = NULL;
|
ctx->final_buf = NULL;
|
||||||
ctx->trigger_pattern = 0x00; /* Value irrelevant, see trigger_mask. */
|
ctx->trigger_pattern = 0x00; /* Value irrelevant, see trigger_mask. */
|
||||||
|
@ -912,7 +912,7 @@ static void send_block_to_session_bus(struct context *ctx, int block)
|
||||||
logic.length = BS;
|
logic.length = BS;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = ctx->final_buf + (block * BS);
|
logic.data = ctx->final_buf + (block * BS);
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +935,7 @@ static void send_block_to_session_bus(struct context *ctx, int block)
|
||||||
logic.length = trigger_point;
|
logic.length = trigger_point;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = ctx->final_buf + (block * BS);
|
logic.data = ctx->final_buf + (block * BS);
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the SR_DF_TRIGGER packet to the session bus. */
|
/* Send the SR_DF_TRIGGER packet to the session bus. */
|
||||||
|
@ -943,7 +943,7 @@ static void send_block_to_session_bus(struct context *ctx, int block)
|
||||||
(block * BS) + trigger_point);
|
(block * BS) + trigger_point);
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.payload = NULL;
|
packet.payload = NULL;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
/* If at least one sample is located after the trigger... */
|
/* If at least one sample is located after the trigger... */
|
||||||
if (trigger_point < (BS - 1)) {
|
if (trigger_point < (BS - 1)) {
|
||||||
|
@ -956,7 +956,7 @@ static void send_block_to_session_bus(struct context *ctx, int block)
|
||||||
logic.length = BS - trigger_point;
|
logic.length = BS - trigger_point;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = ctx->final_buf + (block * BS) + trigger_point;
|
logic.data = ctx->final_buf + (block * BS) + trigger_point;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
@ -1061,7 +1061,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
|
|
||||||
sr_dbg("la8: Acquisition started successfully.");
|
sr_dbg("la8: Acquisition started successfully.");
|
||||||
|
|
||||||
ctx->session_id = session_data;
|
ctx->session_dev_id = cb_data;
|
||||||
|
|
||||||
/* Send header packet to the session bus. */
|
/* Send header packet to the session bus. */
|
||||||
sr_dbg("la8: Sending SR_DF_HEADER.");
|
sr_dbg("la8: Sending SR_DF_HEADER.");
|
||||||
|
@ -1071,7 +1071,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header.starttime, NULL);
|
gettimeofday(&header.starttime, NULL);
|
||||||
header.samplerate = ctx->cur_samplerate;
|
header.samplerate = ctx->cur_samplerate;
|
||||||
header.num_logic_probes = NUM_PROBES;
|
header.num_logic_probes = NUM_PROBES;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
/* Time when we should be done (for detecting trigger timeouts). */
|
/* Time when we should be done (for detecting trigger timeouts). */
|
||||||
ctx->done = (ctx->divcount + 1) * 0.08388608 + time(NULL)
|
ctx->done = (ctx->divcount + 1) * 0.08388608 + time(NULL)
|
||||||
|
@ -1085,7 +1085,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
@ -1106,7 +1106,7 @@ static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||||
/* Send end packet to the session bus. */
|
/* Send end packet to the session bus. */
|
||||||
sr_dbg("la8: Sending SR_DF_END.");
|
sr_dbg("la8: Sending SR_DF_END.");
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct databag {
|
||||||
uint8_t thread_running;
|
uint8_t thread_running;
|
||||||
uint64_t samples_counter;
|
uint64_t samples_counter;
|
||||||
int dev_index;
|
int dev_index;
|
||||||
gpointer session_data;
|
void *session_dev_id;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ static int default_pattern = PATTERN_SIGROK;
|
||||||
static GThread *my_thread;
|
static GThread *my_thread;
|
||||||
static int thread_running;
|
static int thread_running;
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
|
||||||
|
|
||||||
static int hw_init(const char *devinfo)
|
static int hw_init(const char *devinfo)
|
||||||
{
|
{
|
||||||
|
@ -409,7 +409,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet *packet;
|
struct sr_datafeed_packet *packet;
|
||||||
struct sr_datafeed_header *header;
|
struct sr_datafeed_header *header;
|
||||||
|
@ -422,7 +422,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
mydata->sample_generator = default_pattern;
|
mydata->sample_generator = default_pattern;
|
||||||
mydata->session_data = session_data;
|
mydata->session_dev_id = cb_data;
|
||||||
mydata->dev_index = dev_index;
|
mydata->dev_index = dev_index;
|
||||||
mydata->samples_counter = 0;
|
mydata->samples_counter = 0;
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
g_io_channel_set_buffered(channels[1], FALSE);
|
g_io_channel_set_buffered(channels[1], FALSE);
|
||||||
|
|
||||||
sr_source_add(mydata->pipe_fds[0], G_IO_IN | G_IO_ERR, 40,
|
sr_source_add(mydata->pipe_fds[0], G_IO_IN | G_IO_ERR, 40,
|
||||||
receive_data, session_data);
|
receive_data, mydata->session_dev_id);
|
||||||
|
|
||||||
/* Run the demo thread. */
|
/* Run the demo thread. */
|
||||||
g_thread_init(NULL);
|
g_thread_init(NULL);
|
||||||
|
@ -474,18 +474,19 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header->starttime, NULL);
|
gettimeofday(&header->starttime, NULL);
|
||||||
header->samplerate = cur_samplerate;
|
header->samplerate = cur_samplerate;
|
||||||
header->num_logic_probes = NUM_PROBES;
|
header->num_logic_probes = NUM_PROBES;
|
||||||
sr_session_send(session_data, packet);
|
sr_session_send(mydata->session_dev_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
/* Avoid compiler warnings. */
|
/* Avoid compiler warnings. */
|
||||||
(void)dev_index;
|
(void)dev_index;
|
||||||
(void)session_data;
|
(void)cb_data;
|
||||||
|
|
||||||
/* Stop generate thread. */
|
/* Stop generate thread. */
|
||||||
thread_running = 0;
|
thread_running = 0;
|
||||||
|
|
|
@ -552,7 +552,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
* The FX2 gave up. End the acquisition, the frontend
|
* The FX2 gave up. End the acquisition, the frontend
|
||||||
* will work out that the samplecount is short.
|
* will work out that the samplecount is short.
|
||||||
*/
|
*/
|
||||||
hw_dev_acquisition_stop(-1, ctx->session_data);
|
hw_dev_acquisition_stop(-1, ctx->session_dev_id);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -565,17 +565,17 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
logic.length = cur_buflen;
|
logic.length = cur_buflen;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = cur_buf;
|
logic.data = cur_buf;
|
||||||
sr_session_send(ctx->session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
g_free(cur_buf);
|
g_free(cur_buf);
|
||||||
|
|
||||||
num_samples += cur_buflen;
|
num_samples += cur_buflen;
|
||||||
if (ctx->limit_samples &&
|
if (ctx->limit_samples &&
|
||||||
(unsigned int) num_samples > ctx->limit_samples) {
|
(unsigned int) num_samples > ctx->limit_samples) {
|
||||||
hw_dev_acquisition_stop(-1, ctx->session_data);
|
hw_dev_acquisition_stop(-1, ctx->session_dev_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct sr_datafeed_packet *packet;
|
struct sr_datafeed_packet *packet;
|
||||||
|
@ -589,7 +589,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
ctx = sdi->priv;
|
ctx = sdi->priv;
|
||||||
ctx->session_data = session_data;
|
ctx->session_dev_id = cb_data;
|
||||||
|
|
||||||
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
||||||
sr_err("fx2lafw: %s: packet malloc failed", __func__);
|
sr_err("fx2lafw: %s: packet malloc failed", __func__);
|
||||||
|
@ -633,15 +633,15 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header->starttime, NULL);
|
gettimeofday(&header->starttime, NULL);
|
||||||
header->samplerate = 24000000UL;
|
header->samplerate = 24000000UL;
|
||||||
header->num_logic_probes = ctx->profile->num_probes;
|
header->num_logic_probes = ctx->profile->num_probes;
|
||||||
sr_session_send(session_data, packet);
|
sr_session_send(session_dev_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||||
(void)dev_index;
|
(void)dev_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(session_dev_id, &packet);
|
||||||
|
|
||||||
receive_transfer(NULL);
|
receive_transfer(NULL);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct context {
|
||||||
/* Device/Capture Settings */
|
/* Device/Capture Settings */
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
void *session_data;
|
void *session_dev_id;
|
||||||
|
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
};
|
};
|
||||||
|
|
|
@ -731,7 +731,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
logic.length = 1024;
|
logic.length = 1024;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = logic_out;
|
logic.data = logic_out;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
// Dont bother fixing this yet, keep it "old style"
|
// Dont bother fixing this yet, keep it "old style"
|
||||||
/*
|
/*
|
||||||
|
@ -739,16 +739,16 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
packet.length = 1024;
|
packet.length = 1024;
|
||||||
packet.unitsize = sizeof(double);
|
packet.unitsize = sizeof(double);
|
||||||
packet.payload = analog_out;
|
packet.payload = analog_out;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(ctx->session_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
@ -806,7 +806,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ctx->session_id = session_dev_id;
|
ctx->session_dev_id = cb_data;
|
||||||
sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data, sdi);
|
sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data, sdi);
|
||||||
|
|
||||||
packet.type = SR_DF_HEADER;
|
packet.type = SR_DF_HEADER;
|
||||||
|
@ -816,20 +816,21 @@ static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||||
header.samplerate = ctx->cur_rate;
|
header.samplerate = ctx->cur_rate;
|
||||||
// header.num_analog_probes = 1;
|
// header.num_analog_probes = 1;
|
||||||
header.num_logic_probes = 8;
|
header.num_logic_probes = 8;
|
||||||
sr_session_send(session_dev_id, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME */
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
|
||||||
dev_index = dev_index;
|
/* Avoid compiler warnings. */
|
||||||
|
(void)dev_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_dev_id, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct mso {
|
||||||
double dso_trigger_voltage;
|
double dso_trigger_voltage;
|
||||||
uint16_t dso_trigger_width;
|
uint16_t dso_trigger_width;
|
||||||
struct mso_prototrig protocol_trigger;
|
struct mso_prototrig protocol_trigger;
|
||||||
gpointer session_id;
|
void *session_dev_id;
|
||||||
uint16_t buffer_n;
|
uint16_t buffer_n;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
};
|
};
|
||||||
|
|
|
@ -870,7 +870,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet *packet;
|
struct sr_datafeed_packet *packet;
|
||||||
struct sr_datafeed_header *header;
|
struct sr_datafeed_header *header;
|
||||||
|
@ -995,7 +995,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
sr_source_add(ctx->serial->fd, G_IO_IN, -1, receive_data,
|
sr_source_add(ctx->serial->fd, G_IO_IN, -1, receive_data,
|
||||||
session_data);
|
cb_data);
|
||||||
|
|
||||||
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
||||||
sr_err("ols: %s: packet malloc failed", __func__);
|
sr_err("ols: %s: packet malloc failed", __func__);
|
||||||
|
@ -1015,7 +1015,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header->starttime, NULL);
|
gettimeofday(&header->starttime, NULL);
|
||||||
header->samplerate = ctx->cur_samplerate;
|
header->samplerate = ctx->cur_samplerate;
|
||||||
header->num_logic_probes = NUM_PROBES;
|
header->num_logic_probes = NUM_PROBES;
|
||||||
sr_session_send(session_data, packet);
|
sr_session_send(cb_data, packet);
|
||||||
|
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
@ -1023,7 +1023,8 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
|
||||||
|
@ -1031,7 +1032,7 @@ static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||||
(void)dev_index;
|
(void)dev_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_dev_id, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ static libusb_context *usb_context = NULL;
|
||||||
static int new_saleae_logic_firmware = 0;
|
static int new_saleae_logic_firmware = 0;
|
||||||
|
|
||||||
static int hw_dev_config_set(int dev_index, int hwcap, void *value);
|
static int hw_dev_config_set(int dev_index, int hwcap, void *value);
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the USB configuration to determine if this is a Saleae Logic.
|
* Check the USB configuration to determine if this is a Saleae Logic.
|
||||||
|
@ -726,7 +726,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
* The FX2 gave up. End the acquisition, the frontend
|
* The FX2 gave up. End the acquisition, the frontend
|
||||||
* will work out that the samplecount is short.
|
* will work out that the samplecount is short.
|
||||||
*/
|
*/
|
||||||
hw_dev_acquisition_stop(-1, ctx->session_data);
|
hw_dev_acquisition_stop(-1, ctx->session_dev_id);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -752,7 +752,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
*/
|
*/
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.payload = NULL;
|
packet.payload = NULL;
|
||||||
sr_session_send(ctx->session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send the samples that triggered it, since we're
|
* Send the samples that triggered it, since we're
|
||||||
|
@ -763,7 +763,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
logic.length = ctx->trigger_stage;
|
logic.length = ctx->trigger_stage;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = ctx->trigger_buffer;
|
logic.data = ctx->trigger_buffer;
|
||||||
sr_session_send(ctx->session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
|
|
||||||
ctx->trigger_stage = TRIGGER_FIRED;
|
ctx->trigger_stage = TRIGGER_FIRED;
|
||||||
break;
|
break;
|
||||||
|
@ -795,12 +795,12 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
logic.length = cur_buflen - trigger_offset;
|
logic.length = cur_buflen - trigger_offset;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
logic.data = cur_buf + trigger_offset;
|
logic.data = cur_buf + trigger_offset;
|
||||||
sr_session_send(ctx->session_data, &packet);
|
sr_session_send(ctx->session_dev_id, &packet);
|
||||||
g_free(cur_buf);
|
g_free(cur_buf);
|
||||||
|
|
||||||
num_samples += cur_buflen;
|
num_samples += cur_buflen;
|
||||||
if (ctx->limit_samples && (unsigned int) num_samples > ctx->limit_samples) {
|
if (ctx->limit_samples && (unsigned int) num_samples > ctx->limit_samples) {
|
||||||
hw_dev_acquisition_stop(-1, ctx->session_data);
|
hw_dev_acquisition_stop(-1, ctx->session_dev_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -810,7 +810,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct sr_datafeed_packet *packet;
|
struct sr_datafeed_packet *packet;
|
||||||
|
@ -824,7 +824,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
ctx = sdi->priv;
|
ctx = sdi->priv;
|
||||||
ctx->session_data = session_data;
|
ctx->session_dev_id = cb_data;
|
||||||
|
|
||||||
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
||||||
sr_err("logic: %s: packet malloc failed", __func__);
|
sr_err("logic: %s: packet malloc failed", __func__);
|
||||||
|
@ -868,15 +868,15 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header->starttime, NULL);
|
gettimeofday(&header->starttime, NULL);
|
||||||
header->samplerate = ctx->cur_samplerate;
|
header->samplerate = ctx->cur_samplerate;
|
||||||
header->num_logic_probes = ctx->profile->num_probes;
|
header->num_logic_probes = ctx->profile->num_probes;
|
||||||
sr_session_send(session_data, packet);
|
sr_session_send(ctx->session_dev_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
|
||||||
|
@ -884,7 +884,7 @@ static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||||
(void)dev_index;
|
(void)dev_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
receive_transfer(NULL);
|
receive_transfer(NULL);
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct context {
|
||||||
* opaque session data passed in by the frontend, will be passed back
|
* opaque session data passed in by the frontend, will be passed back
|
||||||
* on the session bus along with samples.
|
* on the session bus along with samples.
|
||||||
*/
|
*/
|
||||||
void *session_data;
|
void *session_dev_id;
|
||||||
|
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
};
|
};
|
||||||
|
|
|
@ -613,7 +613,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
|
@ -655,7 +655,7 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
gettimeofday(&header.starttime, NULL);
|
gettimeofday(&header.starttime, NULL);
|
||||||
header.samplerate = ctx->cur_samplerate;
|
header.samplerate = ctx->cur_samplerate;
|
||||||
header.num_logic_probes = ctx->num_channels;
|
header.num_logic_probes = ctx->num_channels;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
if (!(buf = g_try_malloc(PACKET_SIZE))) {
|
if (!(buf = g_try_malloc(PACKET_SIZE))) {
|
||||||
sr_err("zp: %s: buf malloc failed", __func__);
|
sr_err("zp: %s: buf malloc failed", __func__);
|
||||||
|
@ -676,27 +676,27 @@ static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||||
logic.length = PACKET_SIZE;
|
logic.length = PACKET_SIZE;
|
||||||
logic.unitsize = 4;
|
logic.unitsize = 4;
|
||||||
logic.data = buf;
|
logic.data = buf;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
samples_read += res / 4;
|
samples_read += res / 4;
|
||||||
}
|
}
|
||||||
analyzer_read_stop(ctx->usb->devhdl);
|
analyzer_read_stop(ctx->usb->devhdl);
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_data, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
|
||||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
|
||||||
{
|
{
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_dev_inst *sdi;
|
struct sr_dev_inst *sdi;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
sr_session_send(session_dev_id, &packet);
|
sr_session_send(cb_data, &packet);
|
||||||
|
|
||||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
|
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
|
||||||
sr_err("zp: %s: sdi was NULL", __func__);
|
sr_err("zp: %s: sdi was NULL", __func__);
|
||||||
|
|
Loading…
Reference in New Issue