All frontends will have to include <libsigrok/libsigrok.h> from now on.
This header includes proto.h and version.h, both installed from the
distribution into $INCLUDE/libsigrok/ as well.
The only dynamically changed header is now version.h, which has both
libsigrok and libtool compile-time versions in it.
-sigrok.h
+version.h
ChangeLog
libsigrok_la_LDFLAGS = $(SR_LIB_LDFLAGS)
-include_HEADERS = sigrok.h sigrok-proto.h
-noinst_HEADERS = sigrok-internal.h
+library_includedir = $(includedir)/libsigrok
+library_include_HEADERS = libsigrok.h proto.h version.h
+noinst_HEADERS = libsigrok-internal.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libsigrok.pc
*/
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/**
* Initialize libsigrok.
AC_SUBST(SR_PACKAGE_VERSION)
AC_CONFIG_FILES([Makefile
- sigrok.h
+ version.h
hardware/Makefile
hardware/alsa/Makefile
hardware/asix-sigma/Makefile
#include <stdint.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
static gpointer new_chunk(struct sr_datastore **ds);
#include <stdio.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
static GSList *devs = NULL;
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/**
* Remove unused probes from samples.
#include <unistd.h>
#include <string.h>
#include <alsa/asoundlib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#define NUM_PROBES 2
#define SAMPLE_WIDTH 16
#include <glib/gstdio.h>
#include <ftdi.h>
#include <string.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "asix-sigma.h"
#define USB_VENDOR 0xa600
#include <ftdi.h>
#include <glib.h>
#include <string.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "driver.h"
static GSList *dev_insts = NULL;
#include <ftdi.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "driver.h"
/* Probes are numbered 0-7. */
#include <glib.h>
#include <ftdi.h>
#include <stdint.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#define USB_VENDOR_ID 0x0403
#define USB_PRODUCT_ID 0x6001
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
{
#endif
#include <stdlib.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
// FIXME: Must be moved, or rather passed as function argument.
#ifdef _WIN32
#include <fcntl.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/* TODO: Number of probes should be configurable. */
#define NUM_PROBES 8
#include "fx2lafw.h"
#include "command.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
struct version_info *vi)
#define LIBSIGROK_HARDWARE_FX2LAFW_COMMAND_H
#include <glib.h>
-#include "sigrok.h"
+#include "libsigrok.h"
/* Protocol commands */
#define CMD_GET_FW_VERSION 0xb0
#include <inttypes.h>
#include <libusb.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "fx2lafw.h"
#include "command.h"
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "genericdmm.h"
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "genericdmm.h"
#include <inttypes.h>
#include <glib.h>
#include <libusb.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "config.h"
#include "dso.h"
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "config.h"
#include "dso.h"
#include <string.h>
#include <glib.h>
#include <libudev.h>
#include <arpa/inet.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "link-mso19.h"
#define USB_VENDOR "3195"
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#define MIN_NUM_SAMPLES 1
#include <arpa/inet.h>
#endif
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "ols.h"
#ifdef _WIN32
#include <assert.h>
#include "analyzer.h"
#include "gl_usb.h"
-#include "sigrok-internal.h"
+#include "libsigrok-internal.h"
enum {
HARD_DATA_CHECK_SUM = 0x00,
#define LIBSIGROK_HARDWARE_ZEROPLUS_LOGIC_CUBE_ANALYZER_H
#include <libusb.h>
-#include "sigrok.h"
+#include "libsigrok.h"
#define STATUS_FLAG_NONE 0x00
#define STATUS_FLAG_RESET 0x01
#include <libusb.h>
#include <stdio.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "gl_usb.h"
#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN | \
#define LIBSIGROK_HARDWARE_ZEROPLUS_LOGIC_CUBE_GL_USB_H
#include <libusb.h>
-#include "sigrok.h"
+#include "libsigrok.h"
SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer,
unsigned int size);
#include <glib.h>
#include <libusb.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "analyzer.h"
#define USB_VENDOR 0x0c12
#include <dirent.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/*
* This enumerates which driver capabilities correspond to user-settable
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#define CHUNKSIZE (512 * 1024)
#define DEFAULT_NUM_PROBES 8
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#define NUM_PACKETS 2048
#define PACKET_SIZE 4096
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
extern SR_PRIV struct sr_input_format input_chronovu_la8;
extern SR_PRIV struct sr_input_format input_binary;
--- /dev/null
+/*
+ * This file is part of the sigrok project.
+ *
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBSIGROK_SIGROK_INTERNAL_H
+#define LIBSIGROK_SIGROK_INTERNAL_H
+
+#include <stdarg.h>
+#include <glib.h>
+#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */
+#ifdef HAVE_LIBUSB_1_0
+#include <libusb.h>
+#endif
+
+/*--- Macros ----------------------------------------------------------------*/
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+#ifndef ARRAY_AND_SIZE
+#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
+#endif
+
+/* Size of a datastore chunk in units */
+#define DATASTORE_CHUNKSIZE (512 * 1024)
+
+#ifdef HAVE_LIBUSB_1_0
+struct sr_usb_dev_inst {
+ uint8_t bus;
+ uint8_t address;
+ struct libusb_device_handle *devhdl;
+};
+#endif
+
+#define SERIAL_PARITY_NONE 0
+#define SERIAL_PARITY_EVEN 1
+#define SERIAL_PARITY_ODD 2
+struct sr_serial_dev_inst {
+ char *port;
+ int fd;
+};
+
+#ifdef HAVE_LIBUSB_1_0
+/* USB-specific instances */
+SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
+ uint8_t address, struct libusb_device_handle *hdl);
+SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb);
+#endif
+
+/* Serial-specific instances */
+SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(
+ const char *port, int fd);
+SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial);
+
+/*--- log.c -----------------------------------------------------------------*/
+
+SR_PRIV int sr_log(int loglevel, const char *format, ...);
+SR_PRIV int sr_spew(const char *format, ...);
+SR_PRIV int sr_dbg(const char *format, ...);
+SR_PRIV int sr_info(const char *format, ...);
+SR_PRIV int sr_warn(const char *format, ...);
+SR_PRIV int sr_err(const char *format, ...);
+
+/*--- hwdriver.c ------------------------------------------------------------*/
+
+SR_PRIV void sr_hw_cleanup_all(void);
+
+/*--- session.c -------------------------------------------------------------*/
+
+SR_PRIV int sr_session_send(struct sr_dev *dev,
+ struct sr_datafeed_packet *packet);
+
+/* Generic device instances */
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
+ const char *vendor, const char *model, const char *version);
+SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index);
+SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
+
+SR_PRIV int sr_source_remove(int fd);
+SR_PRIV int sr_source_add(int fd, int events, int timeout,
+ sr_receive_data_callback_t cb, void *cb_data);
+
+/*--- hardware/common/serial.c ----------------------------------------------*/
+
+SR_PRIV GSList *list_serial_ports(void);
+SR_PRIV int serial_open(const char *pathname, int flags);
+SR_PRIV int serial_close(int fd);
+SR_PRIV int serial_flush(int fd);
+SR_PRIV int serial_write(int fd, const void *buf, size_t count);
+SR_PRIV int serial_read(int fd, void *buf, size_t count);
+SR_PRIV void *serial_backup_params(int fd);
+SR_PRIV void serial_restore_params(int fd, void *backup);
+SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
+ int stopbits, int flowcontrol);
+
+/*--- hardware/common/ezusb.c -----------------------------------------------*/
+
+#ifdef HAVE_LIBUSB_1_0
+SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
+SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
+ const char *filename);
+SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
+ const char *filename);
+#endif
+
+/*--- hardware/common/misc.c ------------------------------------------------*/
+
+#ifdef HAVE_LIBUSB_1_0
+SR_PRIV int opendev2(int dev_index, struct sr_dev_inst **sdi,
+ libusb_device *dev, struct libusb_device_descriptor *des,
+ int *skip, uint16_t vid, uint16_t pid, int interface);
+SR_PRIV int opendev3(struct sr_dev_inst **sdi, libusb_device *dev,
+ struct libusb_device_descriptor *des,
+ uint16_t vid, uint16_t pid, int interface);
+#endif
+
+#endif
--- /dev/null
+/*
+ * This file is part of the sigrok project.
+ *
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBSIGROK_SIGROK_H
+#define LIBSIGROK_SIGROK_H
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Status/error codes returned by libsigrok functions.
+ *
+ * All possible return codes of libsigrok functions must be listed here.
+ * Functions should never return hardcoded numbers as status, but rather
+ * use these #defines instead. All error codes are negative numbers.
+ *
+ * The error codes are globally unique in libsigrok, i.e. if one of the
+ * libsigrok functions returns a "malloc error" it must be exactly the same
+ * return value as used by all other functions to indicate "malloc error".
+ * There must be no functions which indicate two different errors via the
+ * same return code.
+ *
+ * Also, for compatibility reasons, no defined return codes are ever removed
+ * or reused for different #defines later. You can only add new #defines and
+ * return codes, but never remove or redefine existing ones.
+ */
+#define SR_OK 0 /* No error */
+#define SR_ERR -1 /* Generic/unspecified error */
+#define SR_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
+#define SR_ERR_ARG -3 /* Function argument error */
+#define SR_ERR_BUG -4 /* Errors hinting at internal bugs */
+#define SR_ERR_SAMPLERATE -5 /* Incorrect samplerate */
+
+#define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */
+#define SR_MAX_PROBENAME_LEN 32
+
+/* Handy little macros */
+#define SR_HZ(n) (n)
+#define SR_KHZ(n) ((n) * 1000)
+#define SR_MHZ(n) ((n) * 1000000)
+#define SR_GHZ(n) ((n) * 1000000000)
+
+#define SR_HZ_TO_NS(n) (1000000000 / (n))
+
+/* libsigrok loglevels. */
+#define SR_LOG_NONE 0 /**< Output no messages at all. */
+#define SR_LOG_ERR 1 /**< Output error messages. */
+#define SR_LOG_WARN 2 /**< Output warnings. */
+#define SR_LOG_INFO 3 /**< Output informational messages. */
+#define SR_LOG_DBG 4 /**< Output debug messages. */
+#define SR_LOG_SPEW 5 /**< Output very noisy debug messages. */
+
+/*
+ * Use SR_API to mark public API symbols, and SR_PRIV for private symbols.
+ *
+ * Variables and functions marked 'static' are private already and don't
+ * need SR_PRIV. However, functions which are not static (because they need
+ * to be used in other libsigrok-internal files) but are also not meant to
+ * be part of the public libsigrok API, must use SR_PRIV.
+ *
+ * This uses the 'visibility' feature of gcc (requires gcc >= 4.0).
+ *
+ * This feature is not available on MinGW/Windows, as it is a feature of
+ * ELF files and MinGW/Windows uses PE files.
+ *
+ * Details: http://gcc.gnu.org/wiki/Visibility
+ */
+
+/* Marks public libsigrok API symbols. */
+#ifndef _WIN32
+#define SR_API __attribute__((visibility("default")))
+#else
+#define SR_API
+#endif
+
+/* Marks private, non-public libsigrok symbols (not part of the API). */
+#ifndef _WIN32
+#define SR_PRIV __attribute__((visibility("hidden")))
+#else
+#define SR_PRIV
+#endif
+
+typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data);
+
+/* Data types used by hardware drivers for dev_config_set() */
+enum {
+ SR_T_UINT64,
+ SR_T_CHAR,
+ SR_T_BOOL,
+ SR_T_FLOAT,
+ SR_T_RATIONAL_PERIOD,
+ SR_T_RATIONAL_VOLT,
+ SR_T_KEYVALUE,
+};
+
+struct sr_rational {
+ /* numerator */
+ uint64_t p;
+ /* denominator */
+ uint64_t q;
+};
+
+/* sr_datafeed_packet.type values */
+enum {
+ SR_DF_HEADER,
+ SR_DF_END,
+ SR_DF_TRIGGER,
+ SR_DF_LOGIC,
+ SR_DF_META_LOGIC,
+ SR_DF_ANALOG,
+ SR_DF_META_ANALOG,
+ SR_DF_FRAME_BEGIN,
+ SR_DF_FRAME_END,
+};
+
+/* sr_datafeed_analog.mq values */
+enum {
+ SR_MQ_VOLTAGE,
+ SR_MQ_CURRENT,
+ SR_MQ_RESISTANCE,
+ SR_MQ_CAPACITANCE,
+ SR_MQ_TEMPERATURE,
+ SR_MQ_FREQUENCY,
+ SR_MQ_DUTY_CYCLE,
+};
+
+/* sr_datafeed_analog.unit values */
+enum {
+ SR_UNIT_VOLT,
+ SR_UNIT_AMPERE,
+ SR_UNIT_OHM,
+ SR_UNIT_FARAD,
+ SR_UNIT_CELSIUS,
+ SR_UNIT_KELVIN,
+ SR_UNIT_HERTZ,
+ SR_UNIT_PERCENTAGE,
+};
+
+struct sr_datafeed_packet {
+ uint16_t type;
+ void *payload;
+};
+
+struct sr_datafeed_header {
+ int feed_version;
+ struct timeval starttime;
+};
+
+struct sr_datafeed_meta_logic {
+ int num_probes;
+ uint64_t samplerate;
+};
+
+struct sr_datafeed_logic {
+ uint64_t length;
+ uint16_t unitsize;
+ void *data;
+};
+
+struct sr_datafeed_meta_analog {
+ int num_probes;
+};
+
+struct sr_datafeed_analog {
+ int num_samples;
+ int mq; /* Measured quantity (e.g. voltage, current, temperature) */
+ int unit; /* Unit in which the MQ is measured. */
+ float *data;
+};
+
+struct sr_input {
+ struct sr_input_format *format;
+ char *param;
+ struct sr_dev *vdev;
+};
+
+struct sr_input_format {
+ char *id;
+ char *description;
+ int (*format_match) (const char *filename);
+ int (*init) (struct sr_input *in);
+ int (*loadfile) (struct sr_input *in, const char *filename);
+};
+
+struct sr_output {
+ struct sr_output_format *format;
+ struct sr_dev *dev;
+ char *param;
+ void *internal;
+};
+
+struct sr_output_format {
+ char *id;
+ char *description;
+ int df_type;
+ int (*init) (struct sr_output *o);
+ int (*data) (struct sr_output *o, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out);
+ int (*event) (struct sr_output *o, int event_type, uint8_t **data_out,
+ uint64_t *length_out);
+};
+
+struct sr_datastore {
+ /* Size in bytes of the number of units stored in this datastore */
+ int ds_unitsize;
+ unsigned int num_units; /* TODO: uint64_t */
+ GSList *chunklist;
+};
+
+/*
+ * This represents a generic device connected to the system.
+ * For device-specific information, ask the driver. The driver_index refers
+ * to the device index within that driver; it may be handling more than one
+ * device. All relevant driver calls take a dev_index parameter for this.
+ */
+struct sr_dev {
+ /* Which driver handles this device */
+ struct sr_dev_driver *driver;
+ /* A driver may handle multiple devices of the same type */
+ int driver_index;
+ /* List of struct sr_probe* */
+ GSList *probes;
+ /* Data acquired by this device, if any */
+ struct sr_datastore *datastore;
+};
+
+enum {
+ SR_PROBE_TYPE_LOGIC,
+};
+
+struct sr_probe {
+ int index;
+ int type;
+ gboolean enabled;
+ char *name;
+ char *trigger;
+};
+
+/* Hardware driver capabilities */
+enum {
+ SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */
+
+ /*--- Device classes ------------------------------------------------*/
+
+ /** The device can act as logic analyzer. */
+ SR_HWCAP_LOGIC_ANALYZER,
+
+ /** The device can act as an oscilloscope. */
+ SR_HWCAP_OSCILLOSCOPE,
+
+ /** The device can act as a multimeter. */
+ SR_HWCAP_MULTIMETER,
+
+ /** The device is a demo device. */
+ SR_HWCAP_DEMO_DEV,
+
+
+ /*--- Device communication ------------------------------------------*/
+ /** Some drivers cannot detect the exact model they're talking to. */
+ SR_HWCAP_MODEL,
+
+ /** Specification on how to connect to a device */
+ SR_HWCAP_CONN,
+
+ /** Serial communication spec: <data bits><parity><stop bit> e.g. 8n1 */
+ SR_HWCAP_SERIALCOMM,
+
+
+ /*--- Device configuration ------------------------------------------*/
+
+ /** The device supports setting/changing its samplerate. */
+ SR_HWCAP_SAMPLERATE,
+
+ /* TODO: Better description? Rename to PROBE_AND_TRIGGER_CONFIG? */
+ /** The device supports setting a probe mask. */
+ SR_HWCAP_PROBECONFIG,
+
+ /** The device supports setting a pre/post-trigger capture ratio. */
+ SR_HWCAP_CAPTURE_RATIO,
+
+ /* TODO? */
+ /** The device supports setting a pattern (pattern generator mode). */
+ SR_HWCAP_PATTERN_MODE,
+
+ /** The device supports Run Length Encoding. */
+ SR_HWCAP_RLE,
+
+ /** The device supports setting trigger slope. */
+ SR_HWCAP_TRIGGER_SLOPE,
+
+ /** Trigger source. */
+ SR_HWCAP_TRIGGER_SOURCE,
+
+ /** Horizontal trigger position */
+ SR_HWCAP_HORIZ_TRIGGERPOS,
+
+ /** Buffer size. */
+ SR_HWCAP_BUFFERSIZE,
+
+ /** Time base. */
+ SR_HWCAP_TIMEBASE,
+
+ /** Filter. */
+ SR_HWCAP_FILTER,
+
+ /** Volts/div. */
+ SR_HWCAP_VDIV,
+
+ /** Coupling. */
+ SR_HWCAP_COUPLING,
+
+
+ /*--- Special stuff -------------------------------------------------*/
+
+ /* TODO: Better description. */
+ /** The device supports specifying a capturefile to inject. */
+ SR_HWCAP_CAPTUREFILE,
+
+ /* TODO: Better description. */
+ /** The device supports specifying the capturefile unit size. */
+ SR_HWCAP_CAPTURE_UNITSIZE,
+
+ /* TODO: Better description. */
+ /** The device supports setting the number of probes. */
+ SR_HWCAP_CAPTURE_NUM_PROBES,
+
+
+ /*--- Acquisition modes ---------------------------------------------*/
+
+ /**
+ * The device supports setting a sample time limit, i.e. how long the
+ * sample acquisition should run (in ms).
+ */
+ SR_HWCAP_LIMIT_MSEC,
+
+ /**
+ * The device supports setting a sample number limit, i.e. how many
+ * samples should be acquired.
+ */
+ SR_HWCAP_LIMIT_SAMPLES,
+
+ /**
+ * The device supports setting a frame limit, i.e. how many
+ * frames should be acquired.
+ */
+ SR_HWCAP_LIMIT_FRAMES,
+
+ /**
+ * The device supports continuous sampling, i.e. neither a time limit
+ * nor a sample number limit has to be supplied, it will just acquire
+ * samples continuously, until explicitly stopped by a certain command.
+ */
+ SR_HWCAP_CONTINUOUS,
+
+};
+
+struct sr_hwcap_option {
+ int hwcap;
+ int type;
+ char *description;
+ char *shortname;
+};
+
+struct sr_dev_inst {
+ int index;
+ int status;
+ int inst_type;
+ char *vendor;
+ char *model;
+ char *version;
+ void *priv;
+};
+
+/* sr_dev_inst types */
+enum {
+ /** Device instance type for USB devices. */
+ SR_INST_USB,
+ /** Device instance type for serial port devices. */
+ SR_INST_SERIAL,
+};
+
+/* Device instance status */
+enum {
+ SR_ST_NOT_FOUND,
+ /* Found, but still booting */
+ SR_ST_INITIALIZING,
+ /* Live, but not in use */
+ SR_ST_INACTIVE,
+ /* Actively in use in a session */
+ SR_ST_ACTIVE,
+};
+
+/*
+ * TODO: This sucks, you just kinda have to "know" the returned type.
+ * TODO: Need a DI to return the number of trigger stages supported.
+ */
+
+/* Device info IDs */
+enum {
+ /* struct sr_dev_inst for this specific device */
+ SR_DI_INST,
+ /* The number of probes connected to this device */
+ SR_DI_NUM_PROBES,
+ /* The probe names on this device */
+ SR_DI_PROBE_NAMES,
+ /* Samplerates supported by this device, (struct sr_samplerates) */
+ SR_DI_SAMPLERATES,
+ /* Types of logic trigger supported, out of "01crf" (char *) */
+ SR_DI_TRIGGER_TYPES,
+ /* The currently set samplerate in Hz (uint64_t) */
+ SR_DI_CUR_SAMPLERATE,
+ /* Supported patterns (in pattern generator mode) */
+ SR_DI_PATTERNS,
+ /* Supported buffer sizes */
+ SR_DI_BUFFERSIZES,
+ /* Supported time bases */
+ SR_DI_TIMEBASES,
+ /* Supported trigger sources */
+ SR_DI_TRIGGER_SOURCES,
+ /* Supported filter targets */
+ SR_DI_FILTERS,
+ /* Valid volts/div values */
+ SR_DI_VDIVS,
+ /* Coupling options */
+ SR_DI_COUPLING,
+};
+
+/*
+ * A device supports either a range of samplerates with steps of a given
+ * granularity, or is limited to a set of defined samplerates. Use either
+ * step or list, but not both.
+ */
+struct sr_samplerates {
+ uint64_t low;
+ uint64_t high;
+ uint64_t step;
+ const uint64_t *list;
+};
+
+struct sr_dev_driver {
+ /* Driver-specific */
+ char *name;
+ char *longname;
+ int api_version;
+ int (*init) (const char *devinfo);
+ int (*cleanup) (void);
+
+ /* Device-specific */
+ int (*dev_open) (int dev_index);
+ int (*dev_close) (int dev_index);
+ const void *(*dev_info_get) (int dev_index, int dev_info_id);
+ int (*dev_status_get) (int dev_index);
+ const int *(*hwcap_get_all) (void);
+ int (*dev_config_set) (int dev_index, int hwcap, const void *value);
+ int (*dev_acquisition_start) (int dev_index, void *session_dev_id);
+ int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
+};
+
+struct sr_session {
+ /* List of struct sr_dev* */
+ GSList *devs;
+ /* list of sr_receive_data_callback_t */
+ GSList *datafeed_callbacks;
+ GTimeVal starttime;
+ gboolean running;
+};
+
+#include "proto.h"
+#include "version.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
#include <stdarg.h>
#include <stdio.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/* Currently selected libsigrok loglevel. Default: SR_LOG_WARN. */
static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
static int data(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
unsigned int num_enabled_probes;
#include <string.h>
#include <glib.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
unsigned int num_enabled_probes;
#include <string.h>
#include <glib.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
unsigned int num_enabled_probes;
#include <string.h>
#include <glib.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
unsigned int num_enabled_probes;
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
GString *header;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
extern SR_PRIV struct sr_output_format output_text_bits;
extern SR_PRIV struct sr_output_format output_text_hex;
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "text.h"
SR_PRIV int init_ascii(struct sr_output *o)
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "text.h"
SR_PRIV int init_bits(struct sr_output *o)
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "text.h"
SR_PRIV int init_hex(struct sr_output *o)
#include <string.h>
#include <glib.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
#include "text.h"
SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
#include <string.h>
#include <glib.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
struct context {
int num_enabled_probes;
--- /dev/null
+/*
+ * This file is part of the sigrok project.
+ *
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBSIGROK_SIGROK_PROTO_H
+#define LIBSIGROK_SIGROK_PROTO_H
+
+/*--- backend.c -------------------------------------------------------------*/
+
+SR_API int sr_init(void);
+SR_API int sr_exit(void);
+
+/*--- log.c -----------------------------------------------------------------*/
+
+typedef int (*sr_log_callback_t)(void *cb_data, int loglevel,
+ const char *format, va_list args);
+
+SR_API int sr_log_loglevel_set(int loglevel);
+SR_API int sr_log_loglevel_get(void);
+SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data);
+SR_API int sr_log_callback_set_default(void);
+SR_API int sr_log_logdomain_set(const char *logdomain);
+SR_API char *sr_log_logdomain_get(void);
+
+/*--- datastore.c -----------------------------------------------------------*/
+
+SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds);
+SR_API int sr_datastore_destroy(struct sr_datastore *ds);
+SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
+ unsigned int length, int in_unitsize,
+ const int *probelist);
+
+/*--- device.c --------------------------------------------------------------*/
+
+SR_API int sr_dev_scan(void);
+SR_API GSList *sr_dev_list(void);
+SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
+ int driver_index);
+SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name);
+SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
+ int probenum);
+SR_API int sr_dev_probe_name_set(struct sr_dev *dev, int probenum,
+ const char *name);
+SR_API int sr_dev_trigger_remove_all(struct sr_dev *dev);
+SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
+ const char *trigger);
+SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap);
+SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data);
+
+/*--- filter.c --------------------------------------------------------------*/
+
+SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
+ const int *probelist, const uint8_t *data_in,
+ uint64_t length_in, uint8_t **data_out,
+ uint64_t *length_out);
+
+/*--- hwdriver.c ------------------------------------------------------------*/
+
+SR_API struct sr_dev_driver **sr_driver_list(void);
+SR_API int sr_driver_init(struct sr_dev_driver *driver);
+SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap);
+SR_API const struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap);
+
+/*--- session.c -------------------------------------------------------------*/
+
+typedef void (*sr_datafeed_callback_t)(struct sr_dev *dev,
+ struct sr_datafeed_packet *packet);
+
+/* Session setup */
+SR_API int sr_session_load(const char *filename);
+SR_API struct sr_session *sr_session_new(void);
+SR_API int sr_session_destroy(void);
+SR_API int sr_session_dev_remove_all(void);
+SR_API int sr_session_dev_add(struct sr_dev *dev);
+
+/* Datafeed setup */
+SR_API int sr_session_datafeed_callback_remove_all(void);
+SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb);
+
+/* Session control */
+SR_API int sr_session_start(void);
+SR_API int sr_session_run(void);
+SR_API int sr_session_halt(void);
+SR_API int sr_session_stop(void);
+SR_API int sr_session_save(const char *filename);
+SR_API int sr_session_source_add(int fd, int events, int timeout,
+ sr_receive_data_callback_t cb, void *cb_data);
+SR_API int sr_session_source_remove(int fd);
+
+/*--- input/input.c ---------------------------------------------------------*/
+
+SR_API struct sr_input_format **sr_input_list(void);
+
+/*--- output/output.c -------------------------------------------------------*/
+
+SR_API struct sr_output_format **sr_output_list(void);
+
+/*--- strutil.c -------------------------------------------------------------*/
+
+SR_API char *sr_samplerate_string(uint64_t samplerate);
+SR_API char *sr_period_string(uint64_t frequency);
+SR_API char *sr_voltage_string(struct sr_rational *voltage);
+SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
+ const char *triggerstring);
+SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
+SR_API uint64_t sr_parse_timestring(const char *timestring);
+SR_API gboolean sr_parse_boolstring(const char *boolstring);
+SR_API int sr_parse_period(const char *periodstr, struct sr_rational *r);
+SR_API int sr_parse_voltage(const char *voltstr, struct sr_rational *r);
+
+/*--- version.c -------------------------------------------------------------*/
+
+SR_API int sr_package_version_major_get(void);
+SR_API int sr_package_version_minor_get(void);
+SR_API int sr_package_version_micro_get(void);
+SR_API const char *sr_package_version_string_get(void);
+
+SR_API int sr_lib_version_current_get(void);
+SR_API int sr_lib_version_revision_get(void);
+SR_API int sr_lib_version_age_get(void);
+SR_API const char *sr_lib_version_string_get(void);
+
+#endif
#include <unistd.h>
#include <string.h>
#include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/* demo.c. TODO: Should not be global! */
extern SR_PRIV GIOChannel channels[2];
#include <unistd.h>
#include <sys/time.h>
#include <zip.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/* size of payloads sent across the session bus */
#define CHUNKSIZE (512 * 1024)
#include <glib.h>
#include <glib/gstdio.h>
#include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
extern struct sr_session *session;
extern SR_PRIV struct sr_dev_driver session_driver;
+++ /dev/null
-/*
- * This file is part of the sigrok project.
- *
- * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBSIGROK_SIGROK_INTERNAL_H
-#define LIBSIGROK_SIGROK_INTERNAL_H
-
-#include <stdarg.h>
-#include <glib.h>
-#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */
-#ifdef HAVE_LIBUSB_1_0
-#include <libusb.h>
-#endif
-
-/*--- Macros ----------------------------------------------------------------*/
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-#endif
-
-#ifndef ARRAY_AND_SIZE
-#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
-#endif
-
-/* Size of a datastore chunk in units */
-#define DATASTORE_CHUNKSIZE (512 * 1024)
-
-#ifdef HAVE_LIBUSB_1_0
-struct sr_usb_dev_inst {
- uint8_t bus;
- uint8_t address;
- struct libusb_device_handle *devhdl;
-};
-#endif
-
-#define SERIAL_PARITY_NONE 0
-#define SERIAL_PARITY_EVEN 1
-#define SERIAL_PARITY_ODD 2
-struct sr_serial_dev_inst {
- char *port;
- int fd;
-};
-
-#ifdef HAVE_LIBUSB_1_0
-/* USB-specific instances */
-SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
- uint8_t address, struct libusb_device_handle *hdl);
-SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb);
-#endif
-
-/* Serial-specific instances */
-SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(
- const char *port, int fd);
-SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial);
-
-/*--- log.c -----------------------------------------------------------------*/
-
-SR_PRIV int sr_log(int loglevel, const char *format, ...);
-SR_PRIV int sr_spew(const char *format, ...);
-SR_PRIV int sr_dbg(const char *format, ...);
-SR_PRIV int sr_info(const char *format, ...);
-SR_PRIV int sr_warn(const char *format, ...);
-SR_PRIV int sr_err(const char *format, ...);
-
-/*--- hwdriver.c ------------------------------------------------------------*/
-
-SR_PRIV void sr_hw_cleanup_all(void);
-
-/*--- session.c -------------------------------------------------------------*/
-
-SR_PRIV int sr_session_send(struct sr_dev *dev,
- struct sr_datafeed_packet *packet);
-
-/* Generic device instances */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
- const char *vendor, const char *model, const char *version);
-SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index);
-SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
-
-SR_PRIV int sr_source_remove(int fd);
-SR_PRIV int sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
-
-/*--- hardware/common/serial.c ----------------------------------------------*/
-
-SR_PRIV GSList *list_serial_ports(void);
-SR_PRIV int serial_open(const char *pathname, int flags);
-SR_PRIV int serial_close(int fd);
-SR_PRIV int serial_flush(int fd);
-SR_PRIV int serial_write(int fd, const void *buf, size_t count);
-SR_PRIV int serial_read(int fd, void *buf, size_t count);
-SR_PRIV void *serial_backup_params(int fd);
-SR_PRIV void serial_restore_params(int fd, void *backup);
-SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
- int stopbits, int flowcontrol);
-
-/*--- hardware/common/ezusb.c -----------------------------------------------*/
-
-#ifdef HAVE_LIBUSB_1_0
-SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
-SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
- const char *filename);
-SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
- const char *filename);
-#endif
-
-/*--- hardware/common/misc.c ------------------------------------------------*/
-
-#ifdef HAVE_LIBUSB_1_0
-SR_PRIV int opendev2(int dev_index, struct sr_dev_inst **sdi,
- libusb_device *dev, struct libusb_device_descriptor *des,
- int *skip, uint16_t vid, uint16_t pid, int interface);
-SR_PRIV int opendev3(struct sr_dev_inst **sdi, libusb_device *dev,
- struct libusb_device_descriptor *des,
- uint16_t vid, uint16_t pid, int interface);
-#endif
-
-#endif
+++ /dev/null
-/*
- * This file is part of the sigrok project.
- *
- * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBSIGROK_SIGROK_PROTO_H
-#define LIBSIGROK_SIGROK_PROTO_H
-
-/*--- backend.c -------------------------------------------------------------*/
-
-SR_API int sr_init(void);
-SR_API int sr_exit(void);
-
-/*--- log.c -----------------------------------------------------------------*/
-
-typedef int (*sr_log_callback_t)(void *cb_data, int loglevel,
- const char *format, va_list args);
-
-SR_API int sr_log_loglevel_set(int loglevel);
-SR_API int sr_log_loglevel_get(void);
-SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data);
-SR_API int sr_log_callback_set_default(void);
-SR_API int sr_log_logdomain_set(const char *logdomain);
-SR_API char *sr_log_logdomain_get(void);
-
-/*--- datastore.c -----------------------------------------------------------*/
-
-SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds);
-SR_API int sr_datastore_destroy(struct sr_datastore *ds);
-SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
- unsigned int length, int in_unitsize,
- const int *probelist);
-
-/*--- device.c --------------------------------------------------------------*/
-
-SR_API int sr_dev_scan(void);
-SR_API GSList *sr_dev_list(void);
-SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
- int driver_index);
-SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name);
-SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
- int probenum);
-SR_API int sr_dev_probe_name_set(struct sr_dev *dev, int probenum,
- const char *name);
-SR_API int sr_dev_trigger_remove_all(struct sr_dev *dev);
-SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
- const char *trigger);
-SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap);
-SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data);
-
-/*--- filter.c --------------------------------------------------------------*/
-
-SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
- const int *probelist, const uint8_t *data_in,
- uint64_t length_in, uint8_t **data_out,
- uint64_t *length_out);
-
-/*--- hwdriver.c ------------------------------------------------------------*/
-
-SR_API struct sr_dev_driver **sr_driver_list(void);
-SR_API int sr_driver_init(struct sr_dev_driver *driver);
-SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap);
-SR_API const struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap);
-
-/*--- session.c -------------------------------------------------------------*/
-
-typedef void (*sr_datafeed_callback_t)(struct sr_dev *dev,
- struct sr_datafeed_packet *packet);
-
-/* Session setup */
-SR_API int sr_session_load(const char *filename);
-SR_API struct sr_session *sr_session_new(void);
-SR_API int sr_session_destroy(void);
-SR_API int sr_session_dev_remove_all(void);
-SR_API int sr_session_dev_add(struct sr_dev *dev);
-
-/* Datafeed setup */
-SR_API int sr_session_datafeed_callback_remove_all(void);
-SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb);
-
-/* Session control */
-SR_API int sr_session_start(void);
-SR_API int sr_session_run(void);
-SR_API int sr_session_halt(void);
-SR_API int sr_session_stop(void);
-SR_API int sr_session_save(const char *filename);
-SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
-SR_API int sr_session_source_remove(int fd);
-
-/*--- input/input.c ---------------------------------------------------------*/
-
-SR_API struct sr_input_format **sr_input_list(void);
-
-/*--- output/output.c -------------------------------------------------------*/
-
-SR_API struct sr_output_format **sr_output_list(void);
-
-/*--- strutil.c -------------------------------------------------------------*/
-
-SR_API char *sr_samplerate_string(uint64_t samplerate);
-SR_API char *sr_period_string(uint64_t frequency);
-SR_API char *sr_voltage_string(struct sr_rational *voltage);
-SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
- const char *triggerstring);
-SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
-SR_API uint64_t sr_parse_timestring(const char *timestring);
-SR_API gboolean sr_parse_boolstring(const char *boolstring);
-SR_API int sr_parse_period(const char *periodstr, struct sr_rational *r);
-SR_API int sr_parse_voltage(const char *voltstr, struct sr_rational *r);
-
-/*--- version.c -------------------------------------------------------------*/
-
-SR_API int sr_package_version_major_get(void);
-SR_API int sr_package_version_minor_get(void);
-SR_API int sr_package_version_micro_get(void);
-SR_API const char *sr_package_version_string_get(void);
-
-SR_API int sr_lib_version_current_get(void);
-SR_API int sr_lib_version_revision_get(void);
-SR_API int sr_lib_version_age_get(void);
-SR_API const char *sr_lib_version_string_get(void);
-
-#endif
+++ /dev/null
-/*
- * This file is part of the sigrok project.
- *
- * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBSIGROK_SIGROK_H
-#define LIBSIGROK_SIGROK_H
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Package version macros (can be used for conditional compilation).
- */
-
-/** The libsigrok package 'major' version number. */
-#define SR_PACKAGE_VERSION_MAJOR @SR_PACKAGE_VERSION_MAJOR@
-
-/** The libsigrok package 'minor' version number. */
-#define SR_PACKAGE_VERSION_MINOR @SR_PACKAGE_VERSION_MINOR@
-
-/** The libsigrok package 'micro' version number. */
-#define SR_PACKAGE_VERSION_MICRO @SR_PACKAGE_VERSION_MICRO@
-
-/** The libsigrok package version ("major.minor.micro") as string. */
-#define SR_PACKAGE_VERSION_STRING "@SR_PACKAGE_VERSION@"
-
-/*
- * Library/libtool version macros (can be used for conditional compilation).
- */
-
-/** The libsigrok libtool 'current' version number. */
-#define SR_LIB_VERSION_CURRENT @SR_LIB_VERSION_CURRENT@
-
-/** The libsigrok libtool 'revision' version number. */
-#define SR_LIB_VERSION_REVISION @SR_LIB_VERSION_REVISION@
-
-/** The libsigrok libtool 'age' version number. */
-#define SR_LIB_VERSION_AGE @SR_LIB_VERSION_AGE@
-
-/** The libsigrok libtool version ("current:revision:age") as string. */
-#define SR_LIB_VERSION_STRING "@SR_LIB_VERSION@"
-
-/*
- * Status/error codes returned by libsigrok functions.
- *
- * All possible return codes of libsigrok functions must be listed here.
- * Functions should never return hardcoded numbers as status, but rather
- * use these #defines instead. All error codes are negative numbers.
- *
- * The error codes are globally unique in libsigrok, i.e. if one of the
- * libsigrok functions returns a "malloc error" it must be exactly the same
- * return value as used by all other functions to indicate "malloc error".
- * There must be no functions which indicate two different errors via the
- * same return code.
- *
- * Also, for compatibility reasons, no defined return codes are ever removed
- * or reused for different #defines later. You can only add new #defines and
- * return codes, but never remove or redefine existing ones.
- */
-#define SR_OK 0 /* No error */
-#define SR_ERR -1 /* Generic/unspecified error */
-#define SR_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
-#define SR_ERR_ARG -3 /* Function argument error */
-#define SR_ERR_BUG -4 /* Errors hinting at internal bugs */
-#define SR_ERR_SAMPLERATE -5 /* Incorrect samplerate */
-
-#define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */
-#define SR_MAX_PROBENAME_LEN 32
-
-/* Handy little macros */
-#define SR_HZ(n) (n)
-#define SR_KHZ(n) ((n) * 1000)
-#define SR_MHZ(n) ((n) * 1000000)
-#define SR_GHZ(n) ((n) * 1000000000)
-
-#define SR_HZ_TO_NS(n) (1000000000 / (n))
-
-/* libsigrok loglevels. */
-#define SR_LOG_NONE 0 /**< Output no messages at all. */
-#define SR_LOG_ERR 1 /**< Output error messages. */
-#define SR_LOG_WARN 2 /**< Output warnings. */
-#define SR_LOG_INFO 3 /**< Output informational messages. */
-#define SR_LOG_DBG 4 /**< Output debug messages. */
-#define SR_LOG_SPEW 5 /**< Output very noisy debug messages. */
-
-/*
- * Use SR_API to mark public API symbols, and SR_PRIV for private symbols.
- *
- * Variables and functions marked 'static' are private already and don't
- * need SR_PRIV. However, functions which are not static (because they need
- * to be used in other libsigrok-internal files) but are also not meant to
- * be part of the public libsigrok API, must use SR_PRIV.
- *
- * This uses the 'visibility' feature of gcc (requires gcc >= 4.0).
- *
- * This feature is not available on MinGW/Windows, as it is a feature of
- * ELF files and MinGW/Windows uses PE files.
- *
- * Details: http://gcc.gnu.org/wiki/Visibility
- */
-
-/* Marks public libsigrok API symbols. */
-#ifndef _WIN32
-#define SR_API __attribute__((visibility("default")))
-#else
-#define SR_API
-#endif
-
-/* Marks private, non-public libsigrok symbols (not part of the API). */
-#ifndef _WIN32
-#define SR_PRIV __attribute__((visibility("hidden")))
-#else
-#define SR_PRIV
-#endif
-
-typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data);
-
-/* Data types used by hardware drivers for dev_config_set() */
-enum {
- SR_T_UINT64,
- SR_T_CHAR,
- SR_T_BOOL,
- SR_T_FLOAT,
- SR_T_RATIONAL_PERIOD,
- SR_T_RATIONAL_VOLT,
- SR_T_KEYVALUE,
-};
-
-struct sr_rational {
- /* numerator */
- uint64_t p;
- /* denominator */
- uint64_t q;
-};
-
-/* sr_datafeed_packet.type values */
-enum {
- SR_DF_HEADER,
- SR_DF_END,
- SR_DF_TRIGGER,
- SR_DF_LOGIC,
- SR_DF_META_LOGIC,
- SR_DF_ANALOG,
- SR_DF_META_ANALOG,
- SR_DF_FRAME_BEGIN,
- SR_DF_FRAME_END,
-};
-
-/* sr_datafeed_analog.mq values */
-enum {
- SR_MQ_VOLTAGE,
- SR_MQ_CURRENT,
- SR_MQ_RESISTANCE,
- SR_MQ_CAPACITANCE,
- SR_MQ_TEMPERATURE,
- SR_MQ_FREQUENCY,
- SR_MQ_DUTY_CYCLE,
-};
-
-/* sr_datafeed_analog.unit values */
-enum {
- SR_UNIT_VOLT,
- SR_UNIT_AMPERE,
- SR_UNIT_OHM,
- SR_UNIT_FARAD,
- SR_UNIT_CELSIUS,
- SR_UNIT_KELVIN,
- SR_UNIT_HERTZ,
- SR_UNIT_PERCENTAGE,
-};
-
-struct sr_datafeed_packet {
- uint16_t type;
- void *payload;
-};
-
-struct sr_datafeed_header {
- int feed_version;
- struct timeval starttime;
-};
-
-struct sr_datafeed_meta_logic {
- int num_probes;
- uint64_t samplerate;
-};
-
-struct sr_datafeed_logic {
- uint64_t length;
- uint16_t unitsize;
- void *data;
-};
-
-struct sr_datafeed_meta_analog {
- int num_probes;
-};
-
-struct sr_datafeed_analog {
- int num_samples;
- int mq; /* Measured quantity (e.g. voltage, current, temperature) */
- int unit; /* Unit in which the MQ is measured. */
- float *data;
-};
-
-struct sr_input {
- struct sr_input_format *format;
- char *param;
- struct sr_dev *vdev;
-};
-
-struct sr_input_format {
- char *id;
- char *description;
- int (*format_match) (const char *filename);
- int (*init) (struct sr_input *in);
- int (*loadfile) (struct sr_input *in, const char *filename);
-};
-
-struct sr_output {
- struct sr_output_format *format;
- struct sr_dev *dev;
- char *param;
- void *internal;
-};
-
-struct sr_output_format {
- char *id;
- char *description;
- int df_type;
- int (*init) (struct sr_output *o);
- int (*data) (struct sr_output *o, const uint8_t *data_in,
- uint64_t length_in, uint8_t **data_out,
- uint64_t *length_out);
- int (*event) (struct sr_output *o, int event_type, uint8_t **data_out,
- uint64_t *length_out);
-};
-
-struct sr_datastore {
- /* Size in bytes of the number of units stored in this datastore */
- int ds_unitsize;
- unsigned int num_units; /* TODO: uint64_t */
- GSList *chunklist;
-};
-
-/*
- * This represents a generic device connected to the system.
- * For device-specific information, ask the driver. The driver_index refers
- * to the device index within that driver; it may be handling more than one
- * device. All relevant driver calls take a dev_index parameter for this.
- */
-struct sr_dev {
- /* Which driver handles this device */
- struct sr_dev_driver *driver;
- /* A driver may handle multiple devices of the same type */
- int driver_index;
- /* List of struct sr_probe* */
- GSList *probes;
- /* Data acquired by this device, if any */
- struct sr_datastore *datastore;
-};
-
-enum {
- SR_PROBE_TYPE_LOGIC,
-};
-
-struct sr_probe {
- int index;
- int type;
- gboolean enabled;
- char *name;
- char *trigger;
-};
-
-/* Hardware driver capabilities */
-enum {
- SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */
-
- /*--- Device classes ------------------------------------------------*/
-
- /** The device can act as logic analyzer. */
- SR_HWCAP_LOGIC_ANALYZER,
-
- /** The device can act as an oscilloscope. */
- SR_HWCAP_OSCILLOSCOPE,
-
- /** The device can act as a multimeter. */
- SR_HWCAP_MULTIMETER,
-
- /** The device is a demo device. */
- SR_HWCAP_DEMO_DEV,
-
-
- /*--- Device communication ------------------------------------------*/
- /** Some drivers cannot detect the exact model they're talking to. */
- SR_HWCAP_MODEL,
-
- /** Specification on how to connect to a device */
- SR_HWCAP_CONN,
-
- /** Serial communication spec: <data bits><parity><stop bit> e.g. 8n1 */
- SR_HWCAP_SERIALCOMM,
-
-
- /*--- Device configuration ------------------------------------------*/
-
- /** The device supports setting/changing its samplerate. */
- SR_HWCAP_SAMPLERATE,
-
- /* TODO: Better description? Rename to PROBE_AND_TRIGGER_CONFIG? */
- /** The device supports setting a probe mask. */
- SR_HWCAP_PROBECONFIG,
-
- /** The device supports setting a pre/post-trigger capture ratio. */
- SR_HWCAP_CAPTURE_RATIO,
-
- /* TODO? */
- /** The device supports setting a pattern (pattern generator mode). */
- SR_HWCAP_PATTERN_MODE,
-
- /** The device supports Run Length Encoding. */
- SR_HWCAP_RLE,
-
- /** The device supports setting trigger slope. */
- SR_HWCAP_TRIGGER_SLOPE,
-
- /** Trigger source. */
- SR_HWCAP_TRIGGER_SOURCE,
-
- /** Horizontal trigger position */
- SR_HWCAP_HORIZ_TRIGGERPOS,
-
- /** Buffer size. */
- SR_HWCAP_BUFFERSIZE,
-
- /** Time base. */
- SR_HWCAP_TIMEBASE,
-
- /** Filter. */
- SR_HWCAP_FILTER,
-
- /** Volts/div. */
- SR_HWCAP_VDIV,
-
- /** Coupling. */
- SR_HWCAP_COUPLING,
-
-
- /*--- Special stuff -------------------------------------------------*/
-
- /* TODO: Better description. */
- /** The device supports specifying a capturefile to inject. */
- SR_HWCAP_CAPTUREFILE,
-
- /* TODO: Better description. */
- /** The device supports specifying the capturefile unit size. */
- SR_HWCAP_CAPTURE_UNITSIZE,
-
- /* TODO: Better description. */
- /** The device supports setting the number of probes. */
- SR_HWCAP_CAPTURE_NUM_PROBES,
-
-
- /*--- Acquisition modes ---------------------------------------------*/
-
- /**
- * The device supports setting a sample time limit, i.e. how long the
- * sample acquisition should run (in ms).
- */
- SR_HWCAP_LIMIT_MSEC,
-
- /**
- * The device supports setting a sample number limit, i.e. how many
- * samples should be acquired.
- */
- SR_HWCAP_LIMIT_SAMPLES,
-
- /**
- * The device supports setting a frame limit, i.e. how many
- * frames should be acquired.
- */
- SR_HWCAP_LIMIT_FRAMES,
-
- /**
- * The device supports continuous sampling, i.e. neither a time limit
- * nor a sample number limit has to be supplied, it will just acquire
- * samples continuously, until explicitly stopped by a certain command.
- */
- SR_HWCAP_CONTINUOUS,
-
-};
-
-struct sr_hwcap_option {
- int hwcap;
- int type;
- char *description;
- char *shortname;
-};
-
-struct sr_dev_inst {
- int index;
- int status;
- int inst_type;
- char *vendor;
- char *model;
- char *version;
- void *priv;
-};
-
-/* sr_dev_inst types */
-enum {
- /** Device instance type for USB devices. */
- SR_INST_USB,
- /** Device instance type for serial port devices. */
- SR_INST_SERIAL,
-};
-
-/* Device instance status */
-enum {
- SR_ST_NOT_FOUND,
- /* Found, but still booting */
- SR_ST_INITIALIZING,
- /* Live, but not in use */
- SR_ST_INACTIVE,
- /* Actively in use in a session */
- SR_ST_ACTIVE,
-};
-
-/*
- * TODO: This sucks, you just kinda have to "know" the returned type.
- * TODO: Need a DI to return the number of trigger stages supported.
- */
-
-/* Device info IDs */
-enum {
- /* struct sr_dev_inst for this specific device */
- SR_DI_INST,
- /* The number of probes connected to this device */
- SR_DI_NUM_PROBES,
- /* The probe names on this device */
- SR_DI_PROBE_NAMES,
- /* Samplerates supported by this device, (struct sr_samplerates) */
- SR_DI_SAMPLERATES,
- /* Types of logic trigger supported, out of "01crf" (char *) */
- SR_DI_TRIGGER_TYPES,
- /* The currently set samplerate in Hz (uint64_t) */
- SR_DI_CUR_SAMPLERATE,
- /* Supported patterns (in pattern generator mode) */
- SR_DI_PATTERNS,
- /* Supported buffer sizes */
- SR_DI_BUFFERSIZES,
- /* Supported time bases */
- SR_DI_TIMEBASES,
- /* Supported trigger sources */
- SR_DI_TRIGGER_SOURCES,
- /* Supported filter targets */
- SR_DI_FILTERS,
- /* Valid volts/div values */
- SR_DI_VDIVS,
- /* Coupling options */
- SR_DI_COUPLING,
-};
-
-/*
- * A device supports either a range of samplerates with steps of a given
- * granularity, or is limited to a set of defined samplerates. Use either
- * step or list, but not both.
- */
-struct sr_samplerates {
- uint64_t low;
- uint64_t high;
- uint64_t step;
- const uint64_t *list;
-};
-
-struct sr_dev_driver {
- /* Driver-specific */
- char *name;
- char *longname;
- int api_version;
- int (*init) (const char *devinfo);
- int (*cleanup) (void);
-
- /* Device-specific */
- int (*dev_open) (int dev_index);
- int (*dev_close) (int dev_index);
- const void *(*dev_info_get) (int dev_index, int dev_info_id);
- int (*dev_status_get) (int dev_index);
- const int *(*hwcap_get_all) (void);
- int (*dev_config_set) (int dev_index, int hwcap, const void *value);
- int (*dev_acquisition_start) (int dev_index, void *session_dev_id);
- int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
-};
-
-struct sr_session {
- /* List of struct sr_dev* */
- GSList *devs;
- /* list of sr_receive_data_callback_t */
- GSList *datafeed_callbacks;
- GTimeVal starttime;
- gboolean running;
-};
-
-#include "sigrok-proto.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
/**
* Convert a numeric samplerate value to its "natural" string representation.
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "sigrok.h"
+#include "libsigrok.h"
SR_API int sr_package_version_major_get(void)
{
--- /dev/null
+/*
+ * This file is part of the sigrok project.
+ *
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBSIGROK_VERSION_H
+#define LIBSIGROK_VERSION_H
+
+/*
+ * Package version macros (can be used for conditional compilation).
+ */
+
+/** The libsigrok package 'major' version number. */
+#define SR_PACKAGE_VERSION_MAJOR @SR_PACKAGE_VERSION_MAJOR@
+
+/** The libsigrok package 'minor' version number. */
+#define SR_PACKAGE_VERSION_MINOR @SR_PACKAGE_VERSION_MINOR@
+
+/** The libsigrok package 'micro' version number. */
+#define SR_PACKAGE_VERSION_MICRO @SR_PACKAGE_VERSION_MICRO@
+
+/** The libsigrok package version ("major.minor.micro") as string. */
+#define SR_PACKAGE_VERSION_STRING "@SR_PACKAGE_VERSION@"
+
+/*
+ * Library/libtool version macros (can be used for conditional compilation).
+ */
+
+/** The libsigrok libtool 'current' version number. */
+#define SR_LIB_VERSION_CURRENT @SR_LIB_VERSION_CURRENT@
+
+/** The libsigrok libtool 'revision' version number. */
+#define SR_LIB_VERSION_REVISION @SR_LIB_VERSION_REVISION@
+
+/** The libsigrok libtool 'age' version number. */
+#define SR_LIB_VERSION_AGE @SR_LIB_VERSION_AGE@
+
+/** The libsigrok libtool version ("current:revision:age") as string. */
+#define SR_LIB_VERSION_STRING "@SR_LIB_VERSION@"
+
+#endif
+