sr: change all drivers to use SR_DF_META_LOGIC

This commit is contained in:
Bert Vermeulen 2012-04-22 20:06:19 +02:00
parent ee7489d234
commit f366e86c68
9 changed files with 79 additions and 21 deletions

View File

@ -1265,6 +1265,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
struct context *ctx; struct context *ctx;
struct sr_datafeed_packet *packet; struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header; struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct clockselect_50 clockselect; struct clockselect_50 clockselect;
int frac, triggerpin, ret; int frac, triggerpin, ret;
uint8_t triggerselect; uint8_t triggerselect;
@ -1366,17 +1367,23 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
return SR_ERR_MALLOC; 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. */ /* Send header packet to the session bus. */
packet->type = SR_DF_HEADER; packet->type = SR_DF_HEADER;
packet->payload = header; packet->payload = header;
header->feed_version = 1; header->feed_version = 1;
gettimeofday(&header->starttime, NULL); gettimeofday(&header->starttime, NULL);
header->samplerate = ctx->cur_samplerate;
header->num_logic_probes = ctx->num_probes;
sr_session_send(ctx->session_dev_id, packet); sr_session_send(ctx->session_dev_id, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = ctx->cur_samplerate;
meta.num_probes = ctx->num_probes;
sr_session_send(ctx->session_dev_id, packet);
/* Add capture source. */
sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
g_free(header); g_free(header);
g_free(packet); g_free(packet);

View File

@ -1016,6 +1016,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
struct context *ctx; struct context *ctx;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_header header; struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
uint8_t buf[4]; uint8_t buf[4];
int bytes_written; int bytes_written;
@ -1069,8 +1070,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet.payload = &header; packet.payload = &header;
header.feed_version = 1; header.feed_version = 1;
gettimeofday(&header.starttime, NULL); gettimeofday(&header.starttime, NULL);
header.samplerate = ctx->cur_samplerate; sr_session_send(ctx->session_dev_id, &packet);
header.num_logic_probes = NUM_PROBES;
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = ctx->cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(ctx->session_dev_id, &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). */

View File

@ -414,6 +414,7 @@ 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;
struct sr_datafeed_meta_logic meta;
struct context *ctx; struct context *ctx;
/* TODO: 'ctx' is never g_free()'d? */ /* TODO: 'ctx' is never g_free()'d? */
@ -473,9 +474,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet->payload = header; packet->payload = header;
header->feed_version = 1; header->feed_version = 1;
gettimeofday(&header->starttime, NULL); gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
header->num_logic_probes = NUM_PROBES;
sr_session_send(ctx->session_dev_id, packet); sr_session_send(ctx->session_dev_id, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(ctx->session_dev_id, packet);
g_free(header); g_free(header);
g_free(packet); g_free(packet);

View File

@ -794,6 +794,7 @@ 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;
struct sr_datafeed_header *header; struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct context *ctx; struct context *ctx;
struct libusb_transfer *transfer; struct libusb_transfer *transfer;
const struct libusb_pollfd **lupfd; const struct libusb_pollfd **lupfd;
@ -848,9 +849,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet->payload = header; packet->payload = header;
header->feed_version = 1; header->feed_version = 1;
gettimeofday(&header->starttime, NULL); gettimeofday(&header->starttime, NULL);
header->samplerate = ctx->cur_samplerate;
header->num_logic_probes = ctx->profile->num_probes;
sr_session_send(cb_data, packet); sr_session_send(cb_data, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = ctx->cur_samplerate;
meta.num_probes = ctx->profile->num_probes;
sr_session_send(cb_data, packet);
g_free(header); g_free(header);
g_free(packet); g_free(packet);

View File

@ -876,6 +876,7 @@ 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;
struct sr_datafeed_meta_logic meta;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct context *ctx; struct context *ctx;
uint32_t trigger_config[4]; uint32_t trigger_config[4];
@ -1015,8 +1016,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet->payload = (unsigned char *)header; packet->payload = (unsigned char *)header;
header->feed_version = 1; header->feed_version = 1;
gettimeofday(&header->starttime, NULL); gettimeofday(&header->starttime, NULL);
header->samplerate = ctx->cur_samplerate; sr_session_send(cb_data, packet);
header->num_logic_probes = NUM_PROBES;
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = ctx->cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(cb_data, packet); sr_session_send(cb_data, packet);
g_free(header); g_free(header);

View File

@ -633,6 +633,7 @@ 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_logic logic; struct sr_datafeed_logic logic;
struct sr_datafeed_header header; struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
uint64_t samples_read; uint64_t samples_read;
int res; int res;
unsigned int packet_num; unsigned int packet_num;
@ -667,8 +668,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet.payload = &header; packet.payload = &header;
header.feed_version = 1; header.feed_version = 1;
gettimeofday(&header.starttime, NULL); gettimeofday(&header.starttime, NULL);
header.samplerate = ctx->cur_samplerate; sr_session_send(cb_data, &packet);
header.num_logic_probes = ctx->num_channels;
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = ctx->cur_samplerate;
meta.num_probes = ctx->num_channels;
sr_session_send(cb_data, &packet); sr_session_send(cb_data, &packet);
if (!(buf = g_try_malloc(PACKET_SIZE))) { if (!(buf = g_try_malloc(PACKET_SIZE))) {

View File

@ -67,6 +67,7 @@ static int loadfile(struct sr_input *in, const char *filename)
{ {
struct sr_datafeed_header header; struct sr_datafeed_header header;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_meta_logic meta;
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
unsigned char buffer[CHUNKSIZE]; unsigned char buffer[CHUNKSIZE];
int fd, size, num_probes; int fd, size, num_probes;
@ -78,13 +79,18 @@ static int loadfile(struct sr_input *in, const char *filename)
/* send header */ /* send header */
header.feed_version = 1; header.feed_version = 1;
header.num_logic_probes = num_probes;
header.samplerate = 0;
gettimeofday(&header.starttime, NULL); gettimeofday(&header.starttime, NULL);
packet.type = SR_DF_HEADER; packet.type = SR_DF_HEADER;
packet.payload = &header; packet.payload = &header;
sr_session_send(in->vdev, &packet); sr_session_send(in->vdev, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = 0;
meta.num_probes = num_probes;
sr_session_send(in->vdev, &packet);
/* chop up the input file into chunks and feed it into the session bus */ /* chop up the input file into chunks and feed it into the session bus */
packet.type = SR_DF_LOGIC; packet.type = SR_DF_LOGIC;
packet.payload = &logic; packet.payload = &logic;

View File

@ -123,6 +123,7 @@ static int loadfile(struct sr_input *in, const char *filename)
{ {
struct sr_datafeed_header header; struct sr_datafeed_header header;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_meta_logic meta;
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
uint8_t buf[PACKET_SIZE], divcount; uint8_t buf[PACKET_SIZE], divcount;
int i, fd, size, num_probes; int i, fd, size, num_probes;
@ -153,8 +154,13 @@ static int loadfile(struct sr_input *in, const char *filename)
packet.payload = &header; packet.payload = &header;
header.feed_version = 1; header.feed_version = 1;
gettimeofday(&header.starttime, NULL); gettimeofday(&header.starttime, NULL);
header.num_logic_probes = num_probes; sr_session_send(in->vdev, &packet);
header.samplerate = samplerate;
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = samplerate;
meta.num_probes = num_probes;
sr_session_send(in->vdev, &packet); sr_session_send(in->vdev, &packet);
/* TODO: Handle trigger point. */ /* TODO: Handle trigger point. */

View File

@ -274,6 +274,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
struct session_vdev *vdev; struct session_vdev *vdev;
struct sr_datafeed_header *header; struct sr_datafeed_header *header;
struct sr_datafeed_packet *packet; struct sr_datafeed_packet *packet;
struct sr_datafeed_meta_logic meta;
int ret; int ret;
if (!(vdev = get_vdev_by_index(dev_index))) if (!(vdev = get_vdev_by_index(dev_index)))
@ -318,9 +319,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
packet->payload = (unsigned char *)header; packet->payload = (unsigned char *)header;
header->feed_version = 1; header->feed_version = 1;
gettimeofday(&header->starttime, NULL); gettimeofday(&header->starttime, NULL);
header->samplerate = vdev->samplerate;
header->num_logic_probes = vdev->num_probes;
sr_session_send(cb_data, packet); sr_session_send(cb_data, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = vdev->samplerate;
meta.num_probes = vdev->num_probes;
sr_session_send(cb_data, packet);
g_free(header); g_free(header);
g_free(packet); g_free(packet);