2 * This file is part of the sigrok project.
4 * Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <sys/types.h>
38 #include <arpa/inet.h>
42 #include <sigrok-internal.h>
46 #define O_NONBLOCK FIONBIO
49 static int capabilities[] = {
50 SR_HWCAP_LOGIC_ANALYZER,
52 SR_HWCAP_CAPTURE_RATIO,
53 SR_HWCAP_LIMIT_SAMPLES,
57 /* default supported samplerates, can be overridden by device metadata */
58 static struct sr_samplerates samplerates = {
65 /* List of struct sr_serial_device_instance */
66 static GSList *device_instances = NULL;
68 static int send_shortcommand(int fd, uint8_t command)
72 sr_dbg("ols: sending cmd 0x%.2x", command);
74 if (serial_write(fd, buf, 1) != 1)
80 static int send_longcommand(int fd, uint8_t command, uint32_t data)
84 sr_dbg("ols: sending cmd 0x%.2x data 0x%.8x", command, data);
86 buf[1] = (data & 0xff000000) >> 24;
87 buf[2] = (data & 0xff0000) >> 16;
88 buf[3] = (data & 0xff00) >> 8;
90 if (serial_write(fd, buf, 5) != 5)
96 static int configure_probes(struct ols_device *ols, GSList *probes)
98 struct sr_probe *probe;
100 int probe_bit, stage, i;
104 for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
105 ols->trigger_mask[i] = 0;
106 ols->trigger_value[i] = 0;
110 for (l = probes; l; l = l->next) {
111 probe = (struct sr_probe *)l->data;
116 * Set up the probe mask for later configuration into the
119 probe_bit = 1 << (probe->index - 1);
120 ols->probe_mask |= probe_bit;
125 /* Configure trigger mask and value. */
127 for (tc = probe->trigger; tc && *tc; tc++) {
128 ols->trigger_mask[stage] |= probe_bit;
130 ols->trigger_value[stage] |= probe_bit;
134 * TODO: Only supporting parallel mode, with
139 if (stage > ols->num_stages)
140 ols->num_stages = stage;
146 static uint32_t reverse16(uint32_t in)
150 out = (in & 0xff) << 8;
151 out |= (in & 0xff00) >> 8;
152 out |= (in & 0xff0000) << 8;
153 out |= (in & 0xff000000) >> 8;
158 static uint32_t reverse32(uint32_t in)
162 out = (in & 0xff) << 24;
163 out |= (in & 0xff00) << 8;
164 out |= (in & 0xff0000) >> 8;
165 out |= (in & 0xff000000) >> 24;
170 static struct ols_device *ols_device_new(void)
172 struct ols_device *ols;
174 /* TODO: Is 'ols' ever g_free()'d? */
175 if (!(ols = g_try_malloc0(sizeof(struct ols_device)))) {
176 sr_err("ols: %s: ols malloc failed", __func__);
180 ols->trigger_at = -1;
181 ols->probe_mask = 0xffffffff;
182 ols->cur_samplerate = SR_KHZ(200);
183 ols->period_ps = 5000000;
188 static struct sr_device_instance *get_metadata(int fd)
190 struct sr_device_instance *sdi;
191 struct ols_device *ols;
193 uint8_t key, type, token;
194 GString *tmp_str, *devicename, *version;
197 sdi = sr_device_instance_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
198 ols = ols_device_new();
201 devicename = g_string_new("");
202 version = g_string_new("");
206 if (serial_read(fd, &key, 1) != 1 || key == 0x00)
212 /* NULL-terminated string */
213 tmp_str = g_string_new("");
214 while (serial_read(fd, &tmp_c, 1) == 1 && tmp_c != '\0')
215 g_string_append_c(tmp_str, tmp_c);
216 sr_dbg("ols: got metadata key 0x%.2x value '%s'",
221 devicename = g_string_append(devicename, tmp_str->str);
224 /* FPGA firmware version */
226 g_string_append(version, ", ");
227 g_string_append(version, "FPGA version ");
228 g_string_append(version, tmp_str->str);
231 /* Ancillary version */
233 g_string_append(version, ", ");
234 g_string_append(version, "Ancillary version ");
235 g_string_append(version, tmp_str->str);
238 sr_info("ols: unknown token 0x%.2x: '%s'",
239 token, tmp_str->str);
242 g_string_free(tmp_str, TRUE);
245 /* 32-bit unsigned integer */
246 if (serial_read(fd, &tmp_int, 4) != 4)
248 tmp_int = reverse32(tmp_int);
249 sr_dbg("ols: got metadata key 0x%.2x value 0x%.8x",
253 /* Number of usable probes */
254 ols->num_probes = tmp_int;
257 /* Amount of sample memory available (bytes) */
258 ols->max_samples = tmp_int;
261 /* Amount of dynamic memory available (bytes) */
262 /* what is this for? */
265 /* Maximum sample rate (hz) */
266 ols->max_samplerate = tmp_int;
269 /* protocol version */
270 ols->protocol_version = tmp_int;
273 sr_info("ols: unknown token 0x%.2x: 0x%.8x",
279 /* 8-bit unsigned integer */
280 if (serial_read(fd, &tmp_c, 1) != 1)
282 sr_dbg("ols: got metadata key 0x%.2x value 0x%.2x",
286 /* Number of usable probes */
287 ols->num_probes = tmp_c;
290 /* protocol version */
291 ols->protocol_version = tmp_c;
294 sr_info("ols: unknown token 0x%.2x: 0x%.2x",
305 sdi->model = devicename->str;
306 sdi->version = version->str;
307 g_string_free(devicename, FALSE);
308 g_string_free(version, FALSE);
313 static int hw_init(const char *deviceinfo)
315 struct sr_device_instance *sdi;
316 struct ols_device *ols;
318 GPollFD *fds, probefd;
319 int devcnt, final_devcnt, num_ports, fd, ret, i;
320 char buf[8], **device_names, **serial_params;
325 ports = g_slist_append(NULL, strdup(deviceinfo));
327 /* No specific device given, so scan all serial ports. */
328 ports = list_serial_ports();
330 num_ports = g_slist_length(ports);
332 if (!(fds = g_try_malloc0(num_ports * sizeof(GPollFD)))) {
333 sr_err("ols: %s: fds malloc failed", __func__);
334 goto hw_init_free_ports; /* TODO: SR_ERR_MALLOC. */
337 if (!(device_names = g_try_malloc(num_ports * sizeof(char *)))) {
338 sr_err("ols: %s: device_names malloc failed", __func__);
339 goto hw_init_free_fds; /* TODO: SR_ERR_MALLOC. */
342 if (!(serial_params = g_try_malloc(num_ports * sizeof(char *)))) {
343 sr_err("ols: %s: serial_params malloc failed", __func__);
344 goto hw_init_free_device_names; /* TODO: SR_ERR_MALLOC. */
348 for (l = ports; l; l = l->next) {
349 /* The discovery procedure is like this: first send the Reset
350 * command (0x00) 5 times, since the device could be anywhere
351 * in a 5-byte command. Then send the ID command (0x02).
352 * If the device responds with 4 bytes ("OLS1" or "SLA1"), we
355 * Since it may take the device a while to respond at 115Kb/s,
356 * we do all the sending first, then wait for all of them to
357 * respond with g_poll().
359 sr_info("ols: probing %s...", (char *)l->data);
360 fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
362 serial_params[devcnt] = serial_backup_params(fd);
363 serial_set_params(fd, 115200, 8, 0, 1, 2);
365 for (i = 0; i < 5; i++) {
366 if ((ret = send_shortcommand(fd,
367 CMD_RESET)) != SR_OK) {
368 /* Serial port is not writable. */
373 serial_restore_params(fd,
374 serial_params[devcnt]);
378 send_shortcommand(fd, CMD_ID);
380 fds[devcnt].events = G_IO_IN;
381 device_names[devcnt] = strdup(l->data);
387 /* 2ms isn't enough for reliable transfer with pl2303, let's try 10 */
390 g_poll(fds, devcnt, 1);
392 for (i = 0; i < devcnt; i++) {
393 if (fds[i].revents != G_IO_IN)
395 if (serial_read(fds[i].fd, buf, 4) != 4)
397 if (strncmp(buf, "1SLO", 4) && strncmp(buf, "1ALS", 4))
400 /* definitely using the OLS protocol, check if it supports
401 * the metadata command
403 send_shortcommand(fds[i].fd, CMD_METADATA);
404 probefd.fd = fds[i].fd;
405 probefd.events = G_IO_IN;
406 if (g_poll(&probefd, 1, 10) > 0) {
408 sdi = get_metadata(fds[i].fd);
409 sdi->index = final_devcnt;
411 /* not an OLS -- some other board that uses the sump protocol */
412 sdi = sr_device_instance_new(final_devcnt, SR_ST_INACTIVE,
413 "Sump", "Logic Analyzer", "v1.0");
414 ols = ols_device_new();
415 ols->num_probes = 32;
418 sdi->serial = sr_serial_device_instance_new(device_names[i], -1);
419 device_instances = g_slist_append(device_instances, sdi);
421 serial_close(fds[i].fd);
425 /* clean up after all the probing */
426 for (i = 0; i < devcnt; i++) {
427 if (fds[i].fd != 0) {
428 serial_restore_params(fds[i].fd, serial_params[i]);
429 serial_close(fds[i].fd);
431 free(serial_params[i]);
432 free(device_names[i]);
435 g_free(serial_params);
436 hw_init_free_device_names:
437 g_free(device_names);
446 static int hw_opendev(int device_index)
448 struct sr_device_instance *sdi;
450 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
453 sdi->serial->fd = serial_open(sdi->serial->port, O_RDWR);
454 if (sdi->serial->fd == -1)
457 sdi->status = SR_ST_ACTIVE;
462 static int hw_closedev(int device_index)
464 struct sr_device_instance *sdi;
466 if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
467 sr_err("ols: %s: sdi was NULL", __func__);
468 return SR_ERR; /* TODO: SR_ERR_ARG? */
472 if (sdi->serial->fd != -1) {
473 serial_close(sdi->serial->fd);
474 sdi->serial->fd = -1;
475 sdi->status = SR_ST_INACTIVE;
481 static void hw_cleanup(void)
484 struct sr_device_instance *sdi;
486 /* Properly close and free all devices. */
487 for (l = device_instances; l; l = l->next) {
489 if (sdi->serial->fd != -1)
490 serial_close(sdi->serial->fd);
491 sr_device_instance_free(sdi);
493 g_slist_free(device_instances);
494 device_instances = NULL;
497 static void *hw_get_device_info(int device_index, int device_info_id)
499 struct sr_device_instance *sdi;
500 struct ols_device *ols;
503 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
508 switch (device_info_id) {
512 case SR_DI_NUM_PROBES:
513 info = GINT_TO_POINTER(NUM_PROBES);
515 case SR_DI_SAMPLERATES:
518 case SR_DI_TRIGGER_TYPES:
519 info = (char *)TRIGGER_TYPES;
521 case SR_DI_CUR_SAMPLERATE:
522 info = &ols->cur_samplerate;
529 static int hw_get_status(int device_index)
531 struct sr_device_instance *sdi;
533 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
534 return SR_ST_NOT_FOUND;
539 static int *hw_get_capabilities(void)
544 static int set_configuration_samplerate(struct sr_device_instance *sdi,
547 struct ols_device *ols;
550 if (ols->max_samplerate) {
551 if (samplerate > ols->max_samplerate)
552 return SR_ERR_SAMPLERATE;
553 } else if (samplerate < samplerates.low || samplerate > samplerates.high)
554 return SR_ERR_SAMPLERATE;
556 ols->cur_samplerate = samplerate;
557 ols->period_ps = 1000000000000 / samplerate;
558 if (samplerate > CLOCK_RATE) {
559 ols->flag_reg |= FLAG_DEMUX;
560 ols->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
562 ols->flag_reg &= ~FLAG_DEMUX;
563 ols->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
569 static int hw_set_configuration(int device_index, int capability, void *value)
571 struct sr_device_instance *sdi;
572 struct ols_device *ols;
576 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
580 if (sdi->status != SR_ST_ACTIVE)
583 switch (capability) {
584 case SR_HWCAP_SAMPLERATE:
586 ret = set_configuration_samplerate(sdi, *tmp_u64);
588 case SR_HWCAP_PROBECONFIG:
589 ret = configure_probes(ols, (GSList *) value);
591 case SR_HWCAP_LIMIT_SAMPLES:
593 if (*tmp_u64 < MIN_NUM_SAMPLES)
595 ols->limit_samples = *tmp_u64;
596 sr_info("ols: sample limit %" PRIu64, ols->limit_samples);
599 case SR_HWCAP_CAPTURE_RATIO:
601 ols->capture_ratio = *tmp_u64;
602 if (ols->capture_ratio < 0 || ols->capture_ratio > 100) {
603 ols->capture_ratio = 0;
615 static int receive_data(int fd, int revents, void *session_data)
617 struct sr_datafeed_packet packet;
618 struct sr_datafeed_logic logic;
619 struct sr_device_instance *sdi;
620 struct ols_device *ols;
622 int count, buflen, num_channels, offset, i, j;
623 unsigned char byte, *buffer;
625 /* find this device's ols_device struct by its fd */
627 for (l = device_instances; l; l = l->next) {
629 if (sdi->serial->fd == fd) {
635 /* shouldn't happen */
638 if (ols->num_transfers++ == 0) {
640 * First time round, means the device started sending data,
641 * and will not stop until done. If it stops sending for
642 * longer than it takes to send a byte, that means it's
643 * finished. We'll double that to 30ms to be sure...
645 sr_source_remove(fd);
646 sr_source_add(fd, G_IO_IN, 30, receive_data, session_data);
647 ols->raw_sample_buf = g_try_malloc(ols->limit_samples * 4);
648 if (!ols->raw_sample_buf) {
649 sr_err("ols: %s: ols->raw_sample_buf malloc failed",
653 /* fill with 1010... for debugging */
654 memset(ols->raw_sample_buf, 0x82, ols->limit_samples * 4);
658 for (i = 0x20; i > 0x02; i /= 2) {
659 if ((ols->flag_reg & i) == 0)
663 if (revents == G_IO_IN
664 && ols->num_transfers / num_channels <= ols->limit_samples) {
665 if (serial_read(fd, &byte, 1) != 1)
668 ols->sample[ols->num_bytes++] = byte;
669 sr_dbg("ols: received byte 0x%.2x", byte);
670 if (ols->num_bytes == num_channels) {
671 /* Got a full sample. */
672 sr_dbg("ols: received sample 0x%.*x",
673 ols->num_bytes * 2, (int) *ols->sample);
674 if (ols->flag_reg & FLAG_RLE) {
676 * In RLE mode -1 should never come in as a
677 * sample, because bit 31 is the "count" flag.
678 * TODO: Endianness may be wrong here, could be
681 if (ols->sample[0] & 0x80
682 && !(ols->last_sample[0] & 0x80)) {
683 count = (int)(*ols->sample) & 0x7fffffff;
684 if (!(buffer = g_try_malloc(count))) {
685 sr_err("ols: %s: buffer malloc "
691 for (i = 0; i < count; i++) {
692 memcpy(buffer + buflen, ols->last_sample, 4);
697 * Just a single sample, next sample
698 * will probably be a count referring
699 * to this -- but this one is still a
700 * part of the stream.
702 buffer = ols->sample;
706 /* No compression. */
707 buffer = ols->sample;
711 if (num_channels < 4) {
713 * Some channel groups may have been turned
714 * off, to speed up transfer between the
715 * hardware and the PC. Expand that here before
716 * submitting it over the session bus --
717 * whatever is listening on the bus will be
718 * expecting a full 32-bit sample, based on
719 * the number of probes.
722 memset(ols->tmp_sample, 0, 4);
723 for (i = 0; i < 4; i++) {
724 if (((ols->flag_reg >> 2) & (1 << i)) == 0) {
726 * This channel group was
727 * enabled, copy from received
730 ols->tmp_sample[i] = ols->sample[j++];
733 memcpy(ols->sample, ols->tmp_sample, 4);
734 sr_dbg("ols: full sample 0x%.8x", (int) *ols->sample);
737 /* the OLS sends its sample buffer backwards.
738 * store it in reverse order here, so we can dump
739 * this on the session bus later.
741 offset = (ols->limit_samples - ols->num_transfers / num_channels) * 4;
742 memcpy(ols->raw_sample_buf + offset, ols->sample, 4);
744 if (buffer == ols->sample)
745 memcpy(ols->last_sample, buffer, num_channels);
749 memset(ols->sample, 0, 4);
754 * This is the main loop telling us a timeout was reached, or
755 * we've acquired all the samples we asked for -- we're done.
756 * Send the (properly-ordered) buffer to the frontend.
758 if (ols->trigger_at != -1) {
759 /* a trigger was set up, so we need to tell the frontend
762 if (ols->trigger_at > 0) {
763 /* there are pre-trigger samples, send those first */
764 packet.type = SR_DF_LOGIC;
765 packet.timeoffset = 0;
766 packet.duration = ols->trigger_at * ols->period_ps;
767 packet.payload = &logic;
768 logic.length = ols->trigger_at * 4;
770 logic.data = ols->raw_sample_buf;
771 sr_session_bus(session_data, &packet);
774 /* send the trigger */
775 packet.type = SR_DF_TRIGGER;
776 packet.timeoffset = ols->trigger_at * ols->period_ps;
778 sr_session_bus(session_data, &packet);
780 /* send post-trigger samples */
781 packet.type = SR_DF_LOGIC;
782 packet.timeoffset = ols->trigger_at * ols->period_ps;
783 packet.duration = (ols->limit_samples - ols->trigger_at) * ols->period_ps;
784 packet.payload = &logic;
785 logic.length = (ols->limit_samples * 4) - (ols->trigger_at * 4);
787 logic.data = ols->raw_sample_buf + ols->trigger_at * 4;
788 sr_session_bus(session_data, &packet);
790 /* no trigger was used */
791 packet.type = SR_DF_LOGIC;
792 packet.timeoffset = 0;
793 packet.duration = ols->limit_samples * ols->period_ps;
794 packet.payload = &logic;
795 logic.length = ols->limit_samples * 4;
797 logic.data = ols->raw_sample_buf;
798 sr_session_bus(session_data, &packet);
800 g_free(ols->raw_sample_buf);
804 packet.type = SR_DF_END;
805 packet.timeoffset = ols->limit_samples * ols->period_ps;
807 sr_session_bus(session_data, &packet);
813 static int hw_start_acquisition(int device_index, gpointer session_data)
815 struct sr_datafeed_packet *packet;
816 struct sr_datafeed_header *header;
817 struct sr_device_instance *sdi;
818 struct ols_device *ols;
819 uint32_t trigger_config[4];
821 uint16_t readcount, delaycount;
822 uint8_t changrp_mask;
825 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
830 if (sdi->status != SR_ST_ACTIVE)
833 readcount = ols->limit_samples / 4;
835 memset(trigger_config, 0, 16);
836 trigger_config[ols->num_stages - 1] |= 0x08;
837 if (ols->trigger_mask[0]) {
838 delaycount = readcount * (1 - ols->capture_ratio / 100.0);
839 ols->trigger_at = (readcount - delaycount) * 4 - ols->num_stages;
841 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_0,
842 reverse32(ols->trigger_mask[0])) != SR_OK)
844 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_0,
845 reverse32(ols->trigger_value[0])) != SR_OK)
847 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_0,
848 trigger_config[0]) != SR_OK)
851 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_1,
852 reverse32(ols->trigger_mask[1])) != SR_OK)
854 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_1,
855 reverse32(ols->trigger_value[1])) != SR_OK)
857 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_1,
858 trigger_config[1]) != SR_OK)
861 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_2,
862 reverse32(ols->trigger_mask[2])) != SR_OK)
864 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_2,
865 reverse32(ols->trigger_value[2])) != SR_OK)
867 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_2,
868 trigger_config[2]) != SR_OK)
871 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_3,
872 reverse32(ols->trigger_mask[3])) != SR_OK)
874 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_3,
875 reverse32(ols->trigger_value[3])) != SR_OK)
877 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_3,
878 trigger_config[3]) != SR_OK)
881 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_0,
882 ols->trigger_mask[0]) != SR_OK)
884 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_0,
885 ols->trigger_value[0]) != SR_OK)
887 if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_0,
888 0x00000008) != SR_OK)
890 delaycount = readcount;
893 sr_info("ols: setting samplerate to %" PRIu64 " Hz (divider %u, "
894 "demux %s)", ols->cur_samplerate, ols->cur_samplerate_divider,
895 ols->flag_reg & FLAG_DEMUX ? "on" : "off");
896 if (send_longcommand(sdi->serial->fd, CMD_SET_DIVIDER,
897 reverse32(ols->cur_samplerate_divider)) != SR_OK)
900 /* Send sample limit and pre/post-trigger capture ratio. */
901 data = ((readcount - 1) & 0xffff) << 16;
902 data |= (delaycount - 1) & 0xffff;
903 if (send_longcommand(sdi->serial->fd, CMD_CAPTURE_SIZE, reverse16(data)) != SR_OK)
907 * Enable/disable channel groups in the flag register according to the
911 for (i = 0; i < 4; i++) {
912 if (ols->probe_mask & (0xff << (i * 8)))
913 changrp_mask |= (1 << i);
916 /* The flag register wants them here, and 1 means "disable channel". */
917 ols->flag_reg |= ~(changrp_mask << 2) & 0x3c;
918 ols->flag_reg |= FLAG_FILTER;
919 data = ols->flag_reg << 24;
920 if (send_longcommand(sdi->serial->fd, CMD_SET_FLAGS, data) != SR_OK)
923 /* Start acquisition on the device. */
924 if (send_shortcommand(sdi->serial->fd, CMD_RUN) != SR_OK)
927 sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data,
930 if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
931 sr_err("ols: %s: packet malloc failed", __func__);
932 return SR_ERR_MALLOC;
935 if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
936 sr_err("ols: %s: header malloc failed", __func__);
938 return SR_ERR_MALLOC;
941 /* Send header packet to the session bus. */
942 packet->type = SR_DF_HEADER;
943 packet->payload = (unsigned char *)header;
944 header->feed_version = 1;
945 gettimeofday(&header->starttime, NULL);
946 header->samplerate = ols->cur_samplerate;
947 header->num_logic_probes = NUM_PROBES;
948 header->num_analog_probes = 0;
949 sr_session_bus(session_data, packet);
957 static void hw_stop_acquisition(int device_index, gpointer session_device_id)
959 struct sr_datafeed_packet packet;
961 /* Avoid compiler warnings. */
962 device_index = device_index;
964 packet.type = SR_DF_END;
965 sr_session_bus(session_device_id, &packet);
968 struct sr_device_plugin ols_plugin_info = {
970 .longname = "Openbench Logic Sniffer",
973 .cleanup = hw_cleanup,
974 .opendev = hw_opendev,
975 .closedev = hw_closedev,
976 .get_device_info = hw_get_device_info,
977 .get_status = hw_get_status,
978 .get_capabilities = hw_get_capabilities,
979 .set_configuration = hw_set_configuration,
980 .start_acquisition = hw_start_acquisition,
981 .stop_acquisition = hw_stop_acquisition,