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) {
tosend = MIN(2048, n - sent);
packet.type = DF_LOGIC16;
packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
session_bus(user_data, &packet);
@ -854,8 +855,9 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
&trigger);
if (tosend > 0) {
packet.type = DF_LOGIC16;
packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples;
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. */
tosend = n - sent;
packet.type = DF_LOGIC16;
packet.type = DF_LOGIC;
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
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);
if (z > 0) {
packet.type = DF_LOGIC8;
packet.type = DF_LOGIC;
packet.length = z;
packet.unitsize = 1;
packet.payload = c;
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) {
/* there are pre-trigger samples, send those first */
packet.type = DF_LOGIC32;
packet.type = DF_LOGIC;
packet.length = trigger_at * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
session_bus(user_data, &packet);
}
@ -614,13 +615,15 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = 0;
session_bus(user_data, &packet);
packet.type = DF_LOGIC32;
packet.type = DF_LOGIC;
packet.length = (limit_samples * 4) - (trigger_at * 4);
packet.unitsize = 4;
packet.payload = raw_sample_buf + trigger_at * 4;
session_bus(user_data, &packet);
} else {
packet.type = DF_LOGIC32;
packet.type = DF_LOGIC;
packet.length = limit_samples * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
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
* skipping past them.
*/
packet.type = DF_LOGIC8;
packet.type = DF_LOGIC;
packet.length = trigger_stage;
packet.unitsize = 1;
packet.payload = trigger_buffer;
session_bus(user_data, &packet);
@ -645,8 +646,9 @@ void receive_transfer(struct libusb_transfer *transfer)
if (trigger_stage == TRIGGER_FIRED) {
/* Send the incoming transfer to the session bus. */
packet.type = DF_LOGIC8;
packet.type = DF_LOGIC;
packet.length = cur_buflen - trigger_offset;
packet.unitsize = 1;
packet.payload = cur_buf + trigger_offset;
session_bus(user_data, &packet);
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);
#endif
packet.type = DF_LOGIC32;
packet.type = DF_LOGIC;
packet.length = PACKET_SIZE;
packet.unitsize = 4;
packet.payload = buf;
session_bus(session_device_id, &packet);
}

View File

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

View File

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