#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sigrok.h>
-#include <sigrok-internal.h>
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
-#include "config.h"
+#include "sigrok.h"
+#include "sigrok-internal.h"
/* TODO: Number of probes should be configurable. */
#define NUM_PROBES 8
};
/* 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,
NULL,
};
+static const char *probe_names[NUM_PROBES + 1] = {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ NULL,
+};
+
static uint8_t pattern_sigrok[] = {
0x4c, 0x92, 0x92, 0x92, 0x64, 0x00, 0x00, 0x00,
0x82, 0xfe, 0xfe, 0x82, 0x00, 0x00, 0x00, 0x00,
/* 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;
struct sr_device_instance *sdi;
/* Avoid compiler warnings. */
- deviceinfo = deviceinfo;
+ (void)deviceinfo;
sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
static int hw_opendev(int device_index)
{
/* Avoid compiler warnings. */
- device_index = device_index;
+ (void)device_index;
/* Nothing needed so far. */
static int hw_closedev(int device_index)
{
/* Avoid compiler warnings. */
- device_index = device_index;
+ (void)device_index;
/* Nothing needed so far. */
case SR_DI_NUM_PROBES:
info = GINT_TO_POINTER(NUM_PROBES);
break;
+ case SR_DI_PROBE_NAMES:
+ info = probe_names;
+ break;
case SR_DI_SAMPLERATES:
info = &samplerates;
break;
static int hw_get_status(int device_index)
{
/* Avoid compiler warnings. */
- device_index = device_index;
+ (void)device_index;
return SR_ST_ACTIVE;
}
char *stropt;
/* Avoid compiler warnings. */
- device_index = device_index;
+ (void)device_index;
if (capability == SR_HWCAP_PROBECONFIG) {
/* Nothing to do, but must be supported */
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;
gsize z;
/* Avoid compiler warnings. */
- fd = fd;
- revents = revents;
+ (void)fd;
+ (void)revents;
do {
g_io_channel_read_chars(channels[0],
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);
static void hw_stop_acquisition(int device_index, gpointer session_data)
{
/* Avoid compiler warnings. */
- device_index = device_index;
- session_data = session_data;
+ (void)device_index;
+ (void)session_data;
/* Stop generate thread. */
thread_running = 0;
}
-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,