* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <sigrok.h>
-#include <config.h>
+#include <sigrok-internal.h>
/* demo.c */
extern GIOChannel channels[2];
int fd;
int events;
int timeout;
- receive_data_callback cb;
+ sr_receive_data_callback cb;
void *user_data;
};
/* There can only be one session at a time. */
-struct session *session;
+struct sr_session *session;
int num_sources = 0;
struct source *sources = NULL;
int source_timeout = -1;
-struct session *session_new(void)
+struct sr_session *sr_session_new(void)
{
- session = calloc(1, sizeof(struct session));
+ session = calloc(1, sizeof(struct sr_session));
return session;
}
-void session_destroy(void)
+void sr_session_destroy(void)
{
+
g_slist_free(session->devices);
/* TODO: Loop over protocol decoders and free them. */
g_free(session);
}
-void session_device_clear(void)
+void sr_session_device_clear(void)
{
g_slist_free(session->devices);
session->devices = NULL;
}
-int session_device_add(struct sr_device *device)
+int sr_session_device_add(struct sr_device *device)
{
int ret;
- if (device->plugin && device->plugin->open) {
- ret = device->plugin->open(device->plugin_index);
+ if (device->plugin && device->plugin->opendev) {
+ ret = device->plugin->opendev(device->plugin_index);
if (ret != SR_OK)
return ret;
}
return SR_OK;
}
-void session_pa_clear(void)
+#if 0
+void sr_session_pa_clear(void)
{
/*
* The protocols are pointers to the global set of PA plugins,
session->analyzers = NULL;
}
-void session_pa_add(struct analyzer *an)
+void sr_session_pa_add(struct sr_analyzer *an)
{
session->analyzers = g_slist_append(session->analyzers, an);
}
+#endif
-void session_datafeed_callback_clear(void)
+void sr_session_datafeed_callback_clear(void)
{
g_slist_free(session->datafeed_callbacks);
session->datafeed_callbacks = NULL;
}
-void session_datafeed_callback_add(datafeed_callback callback)
+void sr_session_datafeed_callback_add(sr_datafeed_callback callback)
{
session->datafeed_callbacks =
g_slist_append(session->datafeed_callbacks, callback);
}
-static void session_run_poll()
+static void sr_session_run_poll()
{
GPollFD *fds, my_gpollfd;
int ret, i;
}
-int session_start(void)
+int sr_session_start(void)
{
struct sr_device *device;
GSList *l;
int ret;
- g_message("session: starting");
+ sr_info("session: starting");
for (l = session->devices; l; l = l->next) {
device = l->data;
if ((ret = device->plugin->start_acquisition(
return ret;
}
-void session_run(void)
+void sr_session_run(void)
{
- g_message("session: running");
+ sr_info("session: running");
session->running = TRUE;
/* do we have real sources? */
sources[0].cb(-1, 0, sources[0].user_data);
else
/* 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");
+ sr_info("session: halting");
session->running = FALSE;
}
-void session_stop(void)
+void sr_session_stop(void)
{
struct sr_device *device;
GSList *l;
- g_message("session: stopping");
+ sr_info("session: stopping");
session->running = FALSE;
for (l = session->devices; l; l = l->next) {
device = l->data;
- if (device->plugin)
+ if (device->plugin && device->plugin->stop_acquisition)
device->plugin->stop_acquisition(device->plugin_index, device);
}
}
-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;
- datafeed_callback cb;
+ sr_datafeed_callback cb;
/*
* TODO: Send packet through PD pipe, and send the output of that to
}
}
-void session_source_add(int fd, int events, int timeout,
- receive_data_callback callback, void *user_data)
+void sr_session_source_add(int fd, int events, int timeout,
+ sr_receive_data_callback callback, void *user_data)
{
struct source *new_sources, *s;
source_timeout = timeout;
}
-void session_source_remove(int fd)
+void sr_session_source_remove(int fd)
{
struct source *new_sources;
int old, new;