X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fdemo%2Fdemo.c;h=8cfd1c8946a5ca96b43a14b854c4a57c055b78d2;hb=5c64390e5ac8a0052d8b7eeb49c781d86027c814;hp=1492dadf3ad205032889bebd521505077791e040;hpb=cb93f8a927e6fb2cb1d89176766c5c9c398db5c3;p=libsigrok.git diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 1492dadf..8cfd1c89 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -22,14 +22,13 @@ #include #include #include -#include -#include #ifdef _WIN32 #include #include #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 @@ -65,7 +64,7 @@ enum { }; /* FIXME: Should not be global. */ -GIOChannel *channels[2]; +SR_PRIV GIOChannel *channels[2]; struct databag { int pipe_fds[2]; @@ -79,6 +78,7 @@ struct databag { static int capabilities[] = { SR_HWCAP_LOGIC_ANALYZER, + SR_HWCAP_DEMO_DEVICE, SR_HWCAP_SAMPLERATE, SR_HWCAP_PATTERN_MODE, SR_HWCAP_LIMIT_SAMPLES, @@ -102,6 +102,18 @@ static const char *pattern_strings[] = { 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, @@ -116,7 +128,6 @@ static uint8_t pattern_sigrok[] = { /* 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; @@ -185,6 +196,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) 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; @@ -225,7 +239,6 @@ static int hw_set_configuration(int device_index, int capability, void *value) 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; @@ -369,8 +382,6 @@ static int receive_data(int fd, int revents, void *session_data) 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; @@ -454,13 +465,10 @@ static int hw_start_acquisition(int device_index, gpointer session_data) 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); @@ -478,7 +486,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) 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,