Add sr_ prefix to session related API functions.
This commit is contained in:
parent
2872d21ebc
commit
8a2efef2d5
|
@ -244,14 +244,14 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
packet.length = count * sample_size;
|
packet.length = count * sample_size;
|
||||||
packet.unitsize = sample_size;
|
packet.unitsize = sample_size;
|
||||||
packet.payload = outb;
|
packet.payload = outb;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
free(outb);
|
free(outb);
|
||||||
alsa->limit_samples -= count;
|
alsa->limit_samples -= count;
|
||||||
|
|
||||||
} while (alsa->limit_samples > 0);
|
} while (alsa->limit_samples > 0);
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_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;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
free(ufds);
|
free(ufds);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
|
|
|
@ -877,7 +877,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
packet.length = tosend * sizeof(uint16_t);
|
packet.length = tosend * sizeof(uint16_t);
|
||||||
packet.unitsize = 2;
|
packet.unitsize = 2;
|
||||||
packet.payload = samples + sent;
|
packet.payload = samples + sent;
|
||||||
session_bus(sigma->session_id, &packet);
|
sr_session_bus(sigma->session_id, &packet);
|
||||||
|
|
||||||
sent += tosend;
|
sent += tosend;
|
||||||
}
|
}
|
||||||
|
@ -921,7 +921,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
packet.length = tosend * sizeof(uint16_t);
|
packet.length = tosend * sizeof(uint16_t);
|
||||||
packet.unitsize = 2;
|
packet.unitsize = 2;
|
||||||
packet.payload = samples;
|
packet.payload = samples;
|
||||||
session_bus(sigma->session_id, &packet);
|
sr_session_bus(sigma->session_id, &packet);
|
||||||
|
|
||||||
sent += tosend;
|
sent += tosend;
|
||||||
}
|
}
|
||||||
|
@ -931,7 +931,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
packet.payload = 0;
|
packet.payload = 0;
|
||||||
session_bus(sigma->session_id, &packet);
|
sr_session_bus(sigma->session_id, &packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
||||||
packet.length = tosend * sizeof(uint16_t);
|
packet.length = tosend * sizeof(uint16_t);
|
||||||
packet.unitsize = 2;
|
packet.unitsize = 2;
|
||||||
packet.payload = samples + sent;
|
packet.payload = samples + sent;
|
||||||
session_bus(sigma->session_id, &packet);
|
sr_session_bus(sigma->session_id, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
*lastsample = samples[n - 1];
|
*lastsample = samples[n - 1];
|
||||||
|
@ -990,7 +990,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
/* End of samples. */
|
/* End of samples. */
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(sigma->session_id, &packet);
|
sr_session_bus(sigma->session_id, &packet);
|
||||||
|
|
||||||
sigma->state.state = SIGMA_IDLE;
|
sigma->state.state = SIGMA_IDLE;
|
||||||
|
|
||||||
|
@ -1306,7 +1306,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header.protocol_id = SR_PROTO_RAW;
|
header.protocol_id = SR_PROTO_RAW;
|
||||||
header.num_logic_probes = sigma->num_probes;
|
header.num_logic_probes = sigma->num_probes;
|
||||||
header.num_analog_probes = 0;
|
header.num_analog_probes = 0;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
/* Add capture source. */
|
/* Add capture source. */
|
||||||
source_add(0, G_IO_IN, 10, receive_data, sdi);
|
source_add(0, G_IO_IN, 10, receive_data, sdi);
|
||||||
|
|
|
@ -303,7 +303,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
packet.length = z;
|
packet.length = z;
|
||||||
packet.unitsize = 1;
|
packet.unitsize = 1;
|
||||||
packet.payload = c;
|
packet.payload = c;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
}
|
}
|
||||||
} while (z > 0);
|
} while (z > 0);
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
|
|
||||||
/* Send last packet. */
|
/* Send last packet. */
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header->protocol_id = SR_PROTO_RAW;
|
header->protocol_id = SR_PROTO_RAW;
|
||||||
header->num_logic_probes = NUM_PROBES;
|
header->num_logic_probes = NUM_PROBES;
|
||||||
header->num_analog_probes = 0;
|
header->num_analog_probes = 0;
|
||||||
session_bus(session_device_id, packet);
|
sr_session_bus(session_device_id, packet);
|
||||||
free(header);
|
free(header);
|
||||||
free(packet);
|
free(packet);
|
||||||
|
|
||||||
|
|
|
@ -649,17 +649,17 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
packet.length = 1024;
|
packet.length = 1024;
|
||||||
packet.unitsize = 1;
|
packet.unitsize = 1;
|
||||||
packet.payload = logic_out;
|
packet.payload = logic_out;
|
||||||
session_bus(mso->session_id, &packet);
|
sr_session_bus(mso->session_id, &packet);
|
||||||
|
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG;
|
packet.type = SR_DF_ANALOG;
|
||||||
packet.length = 1024;
|
packet.length = 1024;
|
||||||
packet.unitsize = sizeof(double);
|
packet.unitsize = sizeof(double);
|
||||||
packet.payload = analog_out;
|
packet.payload = analog_out;
|
||||||
session_bus(mso->session_id, &packet);
|
sr_session_bus(mso->session_id, &packet);
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(mso->session_id, &packet);
|
sr_session_bus(mso->session_id, &packet);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header.num_analog_probes = 1;
|
header.num_analog_probes = 1;
|
||||||
header.num_logic_probes = 8;
|
header.num_logic_probes = 8;
|
||||||
header.protocol_id = SR_PROTO_RAW;
|
header.protocol_id = SR_PROTO_RAW;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -747,7 +747,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
|
||||||
device_index = device_index;
|
device_index = device_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sr_device_plugin link_mso19_plugin_info = {
|
struct sr_device_plugin link_mso19_plugin_info = {
|
||||||
|
|
|
@ -618,24 +618,24 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
packet.length = trigger_at * 4;
|
packet.length = trigger_at * 4;
|
||||||
packet.unitsize = 4;
|
packet.unitsize = 4;
|
||||||
packet.payload = raw_sample_buf;
|
packet.payload = raw_sample_buf;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
|
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.length = (limit_samples * 4) - (trigger_at * 4);
|
packet.length = (limit_samples * 4) - (trigger_at * 4);
|
||||||
packet.unitsize = 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);
|
sr_session_bus(user_data, &packet);
|
||||||
} else {
|
} else {
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.length = limit_samples * 4;
|
packet.length = limit_samples * 4;
|
||||||
packet.unitsize = 4;
|
packet.unitsize = 4;
|
||||||
packet.payload = raw_sample_buf;
|
packet.payload = raw_sample_buf;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
}
|
}
|
||||||
free(raw_sample_buf);
|
free(raw_sample_buf);
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
serial_close(fd);
|
serial_close(fd);
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -772,7 +772,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header->protocol_id = SR_PROTO_RAW;
|
header->protocol_id = SR_PROTO_RAW;
|
||||||
header->num_logic_probes = NUM_PROBES;
|
header->num_logic_probes = NUM_PROBES;
|
||||||
header->num_analog_probes = 0;
|
header->num_analog_probes = 0;
|
||||||
session_bus(session_device_id, packet);
|
sr_session_bus(session_device_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sr_device_plugin ols_plugin_info = {
|
struct sr_device_plugin ols_plugin_info = {
|
||||||
|
|
|
@ -609,7 +609,7 @@ void receive_transfer(struct libusb_transfer *transfer)
|
||||||
*/
|
*/
|
||||||
packet.type = SR_DF_TRIGGER;
|
packet.type = SR_DF_TRIGGER;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send the samples that triggered it, since we're
|
* Send the samples that triggered it, since we're
|
||||||
|
@ -619,7 +619,7 @@ void receive_transfer(struct libusb_transfer *transfer)
|
||||||
packet.length = trigger_stage;
|
packet.length = trigger_stage;
|
||||||
packet.unitsize = 1;
|
packet.unitsize = 1;
|
||||||
packet.payload = trigger_buffer;
|
packet.payload = trigger_buffer;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
|
|
||||||
trigger_stage = TRIGGER_FIRED;
|
trigger_stage = TRIGGER_FIRED;
|
||||||
break;
|
break;
|
||||||
|
@ -652,7 +652,7 @@ void receive_transfer(struct libusb_transfer *transfer)
|
||||||
packet.length = cur_buflen - trigger_offset;
|
packet.length = cur_buflen - trigger_offset;
|
||||||
packet.unitsize = 1;
|
packet.unitsize = 1;
|
||||||
packet.payload = cur_buf + trigger_offset;
|
packet.payload = cur_buf + trigger_offset;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
g_free(cur_buf);
|
g_free(cur_buf);
|
||||||
|
|
||||||
num_samples += cur_buflen;
|
num_samples += cur_buflen;
|
||||||
|
@ -717,7 +717,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header->protocol_id = SR_PROTO_RAW;
|
header->protocol_id = SR_PROTO_RAW;
|
||||||
header->num_logic_probes = NUM_PROBES;
|
header->num_logic_probes = NUM_PROBES;
|
||||||
header->num_analog_probes = 0;
|
header->num_analog_probes = 0;
|
||||||
session_bus(session_device_id, packet);
|
sr_session_bus(session_device_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
|
@ -733,7 +733,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
|
||||||
device_index = device_index;
|
device_index = device_index;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
receive_transfer(NULL);
|
receive_transfer(NULL);
|
||||||
|
|
||||||
|
|
|
@ -514,7 +514,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header.protocol_id = SR_PROTO_RAW;
|
header.protocol_id = SR_PROTO_RAW;
|
||||||
header.num_logic_probes = num_channels;
|
header.num_logic_probes = num_channels;
|
||||||
header.num_analog_probes = 0;
|
header.num_analog_probes = 0;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
buf = g_malloc(PACKET_SIZE);
|
buf = g_malloc(PACKET_SIZE);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -533,13 +533,13 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
packet.length = PACKET_SIZE;
|
packet.length = PACKET_SIZE;
|
||||||
packet.unitsize = 4;
|
packet.unitsize = 4;
|
||||||
packet.payload = buf;
|
packet.payload = buf;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
}
|
}
|
||||||
analyzer_read_stop(sdi->usb->devhdl);
|
analyzer_read_stop(sdi->usb->devhdl);
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
|
||||||
struct sr_device_instance *sdi;
|
struct sr_device_instance *sdi;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
session_bus(session_device_id, &packet);
|
sr_session_bus(session_device_id, &packet);
|
||||||
|
|
||||||
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
|
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
|
||||||
return; /* TODO: Cry? */
|
return; /* TODO: Cry? */
|
||||||
|
|
|
@ -231,15 +231,11 @@ struct hwcap_option *find_hwcap_option(int hwcap)
|
||||||
|
|
||||||
void source_remove(int fd)
|
void source_remove(int fd)
|
||||||
{
|
{
|
||||||
|
sr_session_source_remove(fd);
|
||||||
session_source_remove(fd);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void source_add(int fd, int events, int timeout, receive_data_callback rcv_cb,
|
void source_add(int fd, int events, int timeout, receive_data_callback rcv_cb,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
|
sr_session_source_add(fd, events, timeout, rcv_cb, user_data);
|
||||||
session_source_add(fd, events, timeout, rcv_cb, user_data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int loadfile(struct sr_input *in, const char *filename)
|
||||||
packet.type = SR_DF_HEADER;
|
packet.type = SR_DF_HEADER;
|
||||||
packet.length = sizeof(struct sr_datafeed_header);
|
packet.length = sizeof(struct sr_datafeed_header);
|
||||||
packet.payload = &header;
|
packet.payload = &header;
|
||||||
session_bus(in->vdevice, &packet);
|
sr_session_bus(in->vdevice, &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;
|
||||||
|
@ -86,14 +86,14 @@ static int loadfile(struct sr_input *in, const char *filename)
|
||||||
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;
|
||||||
session_bus(in->vdevice, &packet);
|
sr_session_bus(in->vdevice, &packet);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* end of stream */
|
/* end of stream */
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(in->vdevice, &packet);
|
sr_session_bus(in->vdevice, &packet);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
34
session.c
34
session.c
|
@ -44,14 +44,14 @@ struct source *sources = NULL;
|
||||||
int source_timeout = -1;
|
int source_timeout = -1;
|
||||||
|
|
||||||
|
|
||||||
struct sr_session *session_new(void)
|
struct sr_session *sr_session_new(void)
|
||||||
{
|
{
|
||||||
session = calloc(1, sizeof(struct sr_session));
|
session = calloc(1, sizeof(struct sr_session));
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_destroy(void)
|
void sr_session_destroy(void)
|
||||||
{
|
{
|
||||||
g_slist_free(session->devices);
|
g_slist_free(session->devices);
|
||||||
|
|
||||||
|
@ -60,13 +60,13 @@ void session_destroy(void)
|
||||||
g_free(session);
|
g_free(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_device_clear(void)
|
void sr_session_device_clear(void)
|
||||||
{
|
{
|
||||||
g_slist_free(session->devices);
|
g_slist_free(session->devices);
|
||||||
session->devices = NULL;
|
session->devices = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_device_add(struct sr_device *device)
|
int sr_session_device_add(struct sr_device *device)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ int session_device_add(struct sr_device *device)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_pa_clear(void)
|
void sr_session_pa_clear(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The protocols are pointers to the global set of PA plugins,
|
* The protocols are pointers to the global set of PA plugins,
|
||||||
|
@ -91,24 +91,24 @@ void session_pa_clear(void)
|
||||||
session->analyzers = NULL;
|
session->analyzers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_pa_add(struct analyzer *an)
|
void sr_session_pa_add(struct analyzer *an)
|
||||||
{
|
{
|
||||||
session->analyzers = g_slist_append(session->analyzers, an);
|
session->analyzers = g_slist_append(session->analyzers, an);
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_datafeed_callback_clear(void)
|
void sr_session_datafeed_callback_clear(void)
|
||||||
{
|
{
|
||||||
g_slist_free(session->datafeed_callbacks);
|
g_slist_free(session->datafeed_callbacks);
|
||||||
session->datafeed_callbacks = NULL;
|
session->datafeed_callbacks = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_datafeed_callback_add(datafeed_callback callback)
|
void sr_session_datafeed_callback_add(datafeed_callback callback)
|
||||||
{
|
{
|
||||||
session->datafeed_callbacks =
|
session->datafeed_callbacks =
|
||||||
g_slist_append(session->datafeed_callbacks, callback);
|
g_slist_append(session->datafeed_callbacks, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void session_run_poll()
|
static void sr_session_run_poll()
|
||||||
{
|
{
|
||||||
GPollFD *fds, my_gpollfd;
|
GPollFD *fds, my_gpollfd;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
@ -150,7 +150,7 @@ static void session_run_poll()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_start(void)
|
int sr_session_start(void)
|
||||||
{
|
{
|
||||||
struct sr_device *device;
|
struct sr_device *device;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
@ -167,7 +167,7 @@ int session_start(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_run(void)
|
void sr_session_run(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
g_message("session: running");
|
g_message("session: running");
|
||||||
|
@ -180,11 +180,11 @@ void session_run(void)
|
||||||
sources[0].cb(-1, 0, sources[0].user_data);
|
sources[0].cb(-1, 0, sources[0].user_data);
|
||||||
else
|
else
|
||||||
/* real sources, use g_poll() main loop */
|
/* real sources, use g_poll() main loop */
|
||||||
session_run_poll();
|
sr_session_run_poll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_halt(void)
|
void sr_session_halt(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
g_message("session: halting");
|
g_message("session: halting");
|
||||||
|
@ -192,7 +192,7 @@ void session_halt(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_stop(void)
|
void sr_session_stop(void)
|
||||||
{
|
{
|
||||||
struct sr_device *device;
|
struct sr_device *device;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
@ -207,7 +207,7 @@ void session_stop(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
void sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
||||||
{
|
{
|
||||||
GSList *l;
|
GSList *l;
|
||||||
datafeed_callback cb;
|
datafeed_callback cb;
|
||||||
|
@ -222,7 +222,7 @@ void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_source_add(int fd, int events, int timeout,
|
void sr_session_source_add(int fd, int events, int timeout,
|
||||||
receive_data_callback callback, void *user_data)
|
receive_data_callback callback, void *user_data)
|
||||||
{
|
{
|
||||||
struct source *new_sources, *s;
|
struct source *new_sources, *s;
|
||||||
|
@ -248,7 +248,7 @@ void session_source_add(int fd, int events, int timeout,
|
||||||
source_timeout = timeout;
|
source_timeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_source_remove(int fd)
|
void sr_session_source_remove(int fd)
|
||||||
{
|
{
|
||||||
struct source *new_sources;
|
struct source *new_sources;
|
||||||
int old, new;
|
int old, new;
|
||||||
|
|
|
@ -90,7 +90,7 @@ static int feed_chunk(int fd, int revents, void *user_data)
|
||||||
packet.length = ret;
|
packet.length = ret;
|
||||||
packet.unitsize = vdevice->unitsize;
|
packet.unitsize = vdevice->unitsize;
|
||||||
packet.payload = buf;
|
packet.payload = buf;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
} else {
|
} else {
|
||||||
/* done with this capture file */
|
/* done with this capture file */
|
||||||
zip_fclose(vdevice->capfile);
|
zip_fclose(vdevice->capfile);
|
||||||
|
@ -103,7 +103,7 @@ static int feed_chunk(int fd, int revents, void *user_data)
|
||||||
if (!got_data) {
|
if (!got_data) {
|
||||||
packet.type = SR_DF_END;
|
packet.type = SR_DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
session_bus(user_data, &packet);
|
sr_session_bus(user_data, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -247,7 +247,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* freewheeling source */
|
/* freewheeling source */
|
||||||
session_source_add(-1, 0, 0, feed_chunk, session_device_id);
|
sr_session_source_add(-1, 0, 0, feed_chunk, session_device_id);
|
||||||
|
|
||||||
/* Send header packet to the session bus. */
|
/* Send header packet to the session bus. */
|
||||||
packet = g_malloc(sizeof(struct sr_datafeed_packet));
|
packet = g_malloc(sizeof(struct sr_datafeed_packet));
|
||||||
|
@ -263,7 +263,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
|
||||||
header->protocol_id = SR_PROTO_RAW;
|
header->protocol_id = SR_PROTO_RAW;
|
||||||
header->num_logic_probes = vdevice->num_probes;
|
header->num_logic_probes = vdevice->num_probes;
|
||||||
header->num_analog_probes = 0;
|
header->num_analog_probes = 0;
|
||||||
session_bus(session_device_id, packet);
|
sr_session_bus(session_device_id, packet);
|
||||||
g_free(header);
|
g_free(header);
|
||||||
g_free(packet);
|
g_free(packet);
|
||||||
|
|
||||||
|
@ -284,5 +284,5 @@ struct sr_device_plugin session_driver = {
|
||||||
hw_get_capabilities,
|
hw_get_capabilities,
|
||||||
hw_set_configuration,
|
hw_set_configuration,
|
||||||
hw_start_acquisition,
|
hw_start_acquisition,
|
||||||
NULL
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern struct sr_session *session;
|
||||||
extern struct sr_device_plugin session_driver;
|
extern struct sr_device_plugin session_driver;
|
||||||
|
|
||||||
|
|
||||||
int session_load(const char *filename)
|
int sr_session_load(const char *filename)
|
||||||
{
|
{
|
||||||
GKeyFile *kf;
|
GKeyFile *kf;
|
||||||
GPtrArray *capturefiles;
|
GPtrArray *capturefiles;
|
||||||
|
@ -77,7 +77,7 @@ int session_load(const char *filename)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
session = session_new();
|
session = sr_session_new();
|
||||||
|
|
||||||
devcnt = 0;
|
devcnt = 0;
|
||||||
capturefiles = g_ptr_array_new_with_free_func(g_free);
|
capturefiles = g_ptr_array_new_with_free_func(g_free);
|
||||||
|
@ -98,7 +98,7 @@ int session_load(const char *filename)
|
||||||
if (devcnt == 0)
|
if (devcnt == 0)
|
||||||
/* first device, init the plugin */
|
/* first device, init the plugin */
|
||||||
device->plugin->init((char *)filename);
|
device->plugin->init((char *)filename);
|
||||||
session_device_add(device);
|
sr_session_device_add(device);
|
||||||
device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTUREFILE, val);
|
device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTUREFILE, val);
|
||||||
g_ptr_array_add(capturefiles, val);
|
g_ptr_array_add(capturefiles, val);
|
||||||
} else if (!strcmp(keys[j], "samplerate")) {
|
} else if (!strcmp(keys[j], "samplerate")) {
|
||||||
|
@ -136,7 +136,7 @@ int session_load(const char *filename)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int session_save(char *filename)
|
int sr_session_save(char *filename)
|
||||||
{
|
{
|
||||||
GSList *l, *p, *d;
|
GSList *l, *p, *d;
|
||||||
FILE *meta;
|
FILE *meta;
|
||||||
|
|
|
@ -97,31 +97,31 @@ typedef void (*datafeed_callback) (struct sr_device *device,
|
||||||
struct sr_datafeed_packet *packet);
|
struct sr_datafeed_packet *packet);
|
||||||
|
|
||||||
/* Session setup */
|
/* Session setup */
|
||||||
int session_load(const char *filename);
|
int sr_session_load(const char *filename);
|
||||||
struct sr_session *session_new(void);
|
struct sr_session *sr_session_new(void);
|
||||||
void session_destroy(void);
|
void sr_session_destroy(void);
|
||||||
void session_device_clear(void);
|
void sr_session_device_clear(void);
|
||||||
int session_device_add(struct sr_device *device);
|
int sr_session_device_add(struct sr_device *device);
|
||||||
|
|
||||||
/* Protocol analyzers setup */
|
/* Protocol analyzers setup */
|
||||||
void session_pa_clear(void);
|
void sr_session_pa_clear(void);
|
||||||
void session_pa_add(struct analyzer *pa);
|
void sr_session_pa_add(struct analyzer *pa);
|
||||||
|
|
||||||
/* Datafeed setup */
|
/* Datafeed setup */
|
||||||
void session_datafeed_callback_clear(void);
|
void sr_session_datafeed_callback_clear(void);
|
||||||
void session_datafeed_callback_add(datafeed_callback callback);
|
void sr_session_datafeed_callback_add(datafeed_callback callback);
|
||||||
|
|
||||||
/* Session control */
|
/* Session control */
|
||||||
int session_start(void);
|
int sr_session_start(void);
|
||||||
void session_run(void);
|
void sr_session_run(void);
|
||||||
void session_halt(void);
|
void sr_session_halt(void);
|
||||||
void session_stop(void);
|
void sr_session_stop(void);
|
||||||
void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet);
|
void sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet);
|
||||||
void make_metadata(char *filename);
|
void make_metadata(char *filename);
|
||||||
int session_save(char *filename);
|
int sr_session_save(char *filename);
|
||||||
void session_source_add(int fd, int events, int timeout,
|
void sr_session_source_add(int fd, int events, int timeout,
|
||||||
receive_data_callback callback, void *user_data);
|
receive_data_callback callback, void *user_data);
|
||||||
void session_source_remove(int fd);
|
void sr_session_source_remove(int fd);
|
||||||
|
|
||||||
/*--- input/input.c ---------------------------------------------------------*/
|
/*--- input/input.c ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue