change all DF_LOGIC* to a single DF_LOGIC type

The datafeed packet has a new field 'unitsize' to denote the number of
bytes per sample in the payload.
This commit is contained in:
Bert Vermeulen 2011-01-09 06:32:38 +01:00
parent af812219f6
commit 4c046c6bcc
7 changed files with 26 additions and 17 deletions

View File

@ -812,8 +812,9 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
while (sent < n) { while (sent < n) {
tosend = MIN(2048, n - sent); tosend = MIN(2048, n - sent);
packet.type = DF_LOGIC16; packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t); packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent; packet.payload = samples + sent;
session_bus(user_data, &packet); session_bus(user_data, &packet);
@ -854,8 +855,9 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
&trigger); &trigger);
if (tosend > 0) { if (tosend > 0) {
packet.type = DF_LOGIC16; packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t); packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples; packet.payload = samples;
session_bus(user_data, &packet); session_bus(user_data, &packet);
@ -871,8 +873,9 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
/* Send rest of the chunk to sigrok. */ /* Send rest of the chunk to sigrok. */
tosend = n - sent; tosend = n - sent;
packet.type = DF_LOGIC16; packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t); packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent; packet.payload = samples + sent;
session_bus(user_data, &packet); session_bus(user_data, &packet);

View File

@ -258,8 +258,9 @@ static int receive_data(int fd, int revents, void *user_data)
z = read(fd, &c, BUFSIZE); z = read(fd, &c, BUFSIZE);
if (z > 0) { if (z > 0) {
packet.type = DF_LOGIC8; packet.type = DF_LOGIC;
packet.length = z; packet.length = z;
packet.unitsize = 1;
packet.payload = c; packet.payload = c;
session_bus(user_data, &packet); session_bus(user_data, &packet);
} }

View File

@ -604,8 +604,9 @@ static int receive_data(int fd, int revents, void *user_data)
*/ */
if (trigger_at > 0) { if (trigger_at > 0) {
/* there are pre-trigger samples, send those first */ /* there are pre-trigger samples, send those first */
packet.type = DF_LOGIC32; packet.type = DF_LOGIC;
packet.length = trigger_at * 4; packet.length = trigger_at * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf; packet.payload = raw_sample_buf;
session_bus(user_data, &packet); session_bus(user_data, &packet);
} }
@ -614,13 +615,15 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = 0; packet.length = 0;
session_bus(user_data, &packet); session_bus(user_data, &packet);
packet.type = DF_LOGIC32; packet.type = DF_LOGIC;
packet.length = (limit_samples * 4) - (trigger_at * 4); packet.length = (limit_samples * 4) - (trigger_at * 4);
packet.unitsize = 4;
packet.payload = raw_sample_buf + trigger_at * 4; packet.payload = raw_sample_buf + trigger_at * 4;
session_bus(user_data, &packet); session_bus(user_data, &packet);
} else { } else {
packet.type = DF_LOGIC32; packet.type = DF_LOGIC;
packet.length = limit_samples * 4; packet.length = limit_samples * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf; packet.payload = raw_sample_buf;
session_bus(user_data, &packet); session_bus(user_data, &packet);
} }

View File

@ -613,8 +613,9 @@ void receive_transfer(struct libusb_transfer *transfer)
* Send the samples that triggered it, since we're * Send the samples that triggered it, since we're
* skipping past them. * skipping past them.
*/ */
packet.type = DF_LOGIC8; packet.type = DF_LOGIC;
packet.length = trigger_stage; packet.length = trigger_stage;
packet.unitsize = 1;
packet.payload = trigger_buffer; packet.payload = trigger_buffer;
session_bus(user_data, &packet); session_bus(user_data, &packet);
@ -645,8 +646,9 @@ void receive_transfer(struct libusb_transfer *transfer)
if (trigger_stage == TRIGGER_FIRED) { if (trigger_stage == TRIGGER_FIRED) {
/* Send the incoming transfer to the session bus. */ /* Send the incoming transfer to the session bus. */
packet.type = DF_LOGIC8; packet.type = DF_LOGIC;
packet.length = cur_buflen - trigger_offset; packet.length = cur_buflen - trigger_offset;
packet.unitsize = 1;
packet.payload = cur_buf + trigger_offset; packet.payload = cur_buf + trigger_offset;
session_bus(user_data, &packet); session_bus(user_data, &packet);
g_free(cur_buf); g_free(cur_buf);

View File

@ -528,8 +528,9 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
PACKET_SIZE, res); PACKET_SIZE, res);
#endif #endif
packet.type = DF_LOGIC32; packet.type = DF_LOGIC;
packet.length = PACKET_SIZE; packet.length = PACKET_SIZE;
packet.unitsize = 4;
packet.payload = buf; packet.payload = buf;
session_bus(session_device_id, &packet); session_bus(session_device_id, &packet);
} }

View File

@ -57,7 +57,8 @@ static int in_loadfile(const char *filename)
packet.payload = &header; packet.payload = &header;
session_bus(device, &packet); session_bus(device, &packet);
packet.type = DF_LOGIC8; packet.type = DF_LOGIC;
packet.unitsize = 1;
packet.payload = buffer; packet.payload = buffer;
while ((size = read(fd, buffer, CHUNKSIZE)) > 0) { while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
packet.length = size; packet.length = size;

View File

@ -89,17 +89,15 @@ enum {
DF_HEADER, DF_HEADER,
DF_END, DF_END,
DF_TRIGGER, DF_TRIGGER,
DF_LOGIC8, DF_LOGIC,
DF_LOGIC16, DF_PD,
DF_LOGIC24, DF_PA,
DF_LOGIC32,
DF_LOGIC48,
DF_LOGIC64,
}; };
struct datafeed_packet { struct datafeed_packet {
uint16_t type; uint16_t type;
uint64_t length; uint64_t length;
uint16_t unitsize;
void *payload; void *payload;
}; };