#include <fcntl.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
-#include "config.h"
#include "sigrok.h"
#include "sigrok-internal.h"
};
/* FIXME: Should not be global. */
-GIOChannel *channels[2];
+SR_PRIV GIOChannel *channels[2];
struct databag {
int pipe_fds[2];
static int capabilities[] = {
SR_HWCAP_LOGIC_ANALYZER,
+ SR_HWCAP_DEMO_DEVICE,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_PATTERN_MODE,
SR_HWCAP_LIMIT_SAMPLES,
/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
static uint64_t cur_samplerate = SR_KHZ(200);
-static uint64_t period_ps = 5000000;
static uint64_t limit_samples = 0;
static uint64_t limit_msec = 0;
static int default_pattern = PATTERN_SIGROK;
static GThread *my_thread;
static int thread_running;
-static void hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int device_index, gpointer session_data);
static int hw_init(const char *deviceinfo)
{
ret = SR_OK;
} else if (capability == SR_HWCAP_SAMPLERATE) {
cur_samplerate = *(uint64_t *)value;
- period_ps = 1000000000000 / cur_samplerate;
sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__,
cur_samplerate);
ret = SR_OK;
if (z > 0) {
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
- packet.timeoffset = samples_received * period_ps;
- packet.duration = z * period_ps;
logic.length = z;
logic.unitsize = 1;
logic.data = c;
packet->type = SR_DF_HEADER;
packet->payload = header;
- packet->timeoffset = 0;
- packet->duration = 0;
header->feed_version = 1;
gettimeofday(&header->starttime, NULL);
header->samplerate = cur_samplerate;
header->num_logic_probes = NUM_PROBES;
- header->num_analog_probes = 0;
sr_session_bus(session_data, packet);
g_free(header);
g_free(packet);
return SR_OK;
}
-static void hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int device_index, gpointer session_data)
{
/* Avoid compiler warnings. */
(void)device_index;
/* Stop generate thread. */
thread_running = 0;
+
+ return SR_OK;
}
-struct sr_device_plugin demo_plugin_info = {
+SR_PRIV struct sr_device_plugin demo_plugin_info = {
.name = "demo",
.longname = "Demo driver and pattern generator",
.api_version = 1,