From: Bert Vermeulen Date: Wed, 4 Jul 2012 22:55:07 +0000 (+0200) Subject: sr: moved sigrok.h so libsigrok/libsigrok.h X-Git-Tag: dsupstream~879 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=45c59c8bdd01954f9214fe7b869d92c55415d109;p=libsigrok.git sr: moved sigrok.h so libsigrok/libsigrok.h All frontends will have to include 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. --- diff --git a/.gitignore b/.gitignore index bb0c2333..9407270d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -sigrok.h +version.h ChangeLog diff --git a/Makefile.am b/Makefile.am index 3bd9f894..f37c2e5d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,8 +46,9 @@ libsigrok_la_LIBADD = \ 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 diff --git a/backend.c b/backend.c index e67f4824..e2b7a466 100644 --- a/backend.c +++ b/backend.c @@ -18,8 +18,8 @@ */ #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" /** * Initialize libsigrok. diff --git a/configure.ac b/configure.ac index d34a7019..495b3b5c 100644 --- a/configure.ac +++ b/configure.ac @@ -283,7 +283,7 @@ AC_SUBST(SR_PACKAGE_VERSION_MICRO) AC_SUBST(SR_PACKAGE_VERSION) AC_CONFIG_FILES([Makefile - sigrok.h + version.h hardware/Makefile hardware/alsa/Makefile hardware/asix-sigma/Makefile diff --git a/datastore.c b/datastore.c index f45353a0..c4b82e67 100644 --- a/datastore.c +++ b/datastore.c @@ -21,8 +21,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" static gpointer new_chunk(struct sr_datastore **ds); diff --git a/device.c b/device.c index 15809e17..d32b4e95 100644 --- a/device.c +++ b/device.c @@ -19,8 +19,8 @@ #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" static GSList *devs = NULL; diff --git a/filter.c b/filter.c index 2465cbbd..0775765f 100644 --- a/filter.c +++ b/filter.c @@ -20,8 +20,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" /** * Remove unused probes from samples. diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index d86ac05f..4fb8c5d5 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -24,8 +24,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #define NUM_PROBES 2 #define SAMPLE_WIDTH 16 diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index c0a7aa42..b5d2b97f 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -27,8 +27,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "asix-sigma.h" #define USB_VENDOR 0xa600 diff --git a/hardware/chronovu-la8/api.c b/hardware/chronovu-la8/api.c index 7d746889..90926c00 100644 --- a/hardware/chronovu-la8/api.c +++ b/hardware/chronovu-la8/api.c @@ -21,8 +21,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "driver.h" static GSList *dev_insts = NULL; diff --git a/hardware/chronovu-la8/driver.c b/hardware/chronovu-la8/driver.c index 37b96c4a..a9e733cb 100644 --- a/hardware/chronovu-la8/driver.c +++ b/hardware/chronovu-la8/driver.c @@ -20,8 +20,8 @@ #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "driver.h" /* Probes are numbered 0-7. */ diff --git a/hardware/chronovu-la8/driver.h b/hardware/chronovu-la8/driver.h index f3a8e013..d972d182 100644 --- a/hardware/chronovu-la8/driver.h +++ b/hardware/chronovu-la8/driver.h @@ -24,8 +24,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #define USB_VENDOR_ID 0x0403 #define USB_PRODUCT_ID 0x6001 diff --git a/hardware/common/ezusb.c b/hardware/common/ezusb.c index 2001a61f..3a547a14 100644 --- a/hardware/common/ezusb.c +++ b/hardware/common/ezusb.c @@ -27,8 +27,8 @@ #include #include #include -#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) { diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 822b4ccd..002b23c3 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -30,8 +30,8 @@ #endif #include #include -#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 diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index eb554787..3a6ed9e4 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -27,8 +27,8 @@ #include #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 diff --git a/hardware/fx2lafw/command.c b/hardware/fx2lafw/command.c index 9bd634b5..5a085bb6 100644 --- a/hardware/fx2lafw/command.c +++ b/hardware/fx2lafw/command.c @@ -21,8 +21,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) diff --git a/hardware/fx2lafw/command.h b/hardware/fx2lafw/command.h index 37f965cc..53e7da3c 100644 --- a/hardware/fx2lafw/command.h +++ b/hardware/fx2lafw/command.h @@ -21,7 +21,7 @@ #define LIBSIGROK_HARDWARE_FX2LAFW_COMMAND_H #include -#include "sigrok.h" +#include "libsigrok.h" /* Protocol commands */ #define CMD_GET_FW_VERSION 0xb0 diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 59ad5e73..be84761a 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -24,8 +24,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "fx2lafw.h" #include "command.h" diff --git a/hardware/genericdmm/api.c b/hardware/genericdmm/api.c index be05fb29..8f332263 100644 --- a/hardware/genericdmm/api.c +++ b/hardware/genericdmm/api.c @@ -22,8 +22,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "genericdmm.h" diff --git a/hardware/genericdmm/fs9922.c b/hardware/genericdmm/fs9922.c index 24acbae5..5e80df77 100644 --- a/hardware/genericdmm/fs9922.c +++ b/hardware/genericdmm/fs9922.c @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "genericdmm.h" diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index 36466bab..8a7e9f74 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -29,8 +29,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "config.h" #include "dso.h" diff --git a/hardware/hantek-dso/dso.c b/hardware/hantek-dso/dso.c index e9d74dfb..77cad923 100644 --- a/hardware/hantek-dso/dso.c +++ b/hardware/hantek-dso/dso.c @@ -19,8 +19,8 @@ * along with this program. If not, see . */ -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "config.h" #include "dso.h" #include diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index abf1fb98..7c25817b 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -28,8 +28,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "link-mso19.h" #define USB_VENDOR "3195" diff --git a/hardware/mastech-va18b/api.c b/hardware/mastech-va18b/api.c index 00172550..54eaea24 100644 --- a/hardware/mastech-va18b/api.c +++ b/hardware/mastech-va18b/api.c @@ -21,8 +21,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #define MIN_NUM_SAMPLES 1 diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 65a04f1a..f2706d11 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -38,8 +38,8 @@ #include #endif #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "ols.h" #ifdef _WIN32 diff --git a/hardware/zeroplus-logic-cube/analyzer.c b/hardware/zeroplus-logic-cube/analyzer.c index 9a416d63..4f86aa50 100644 --- a/hardware/zeroplus-logic-cube/analyzer.c +++ b/hardware/zeroplus-logic-cube/analyzer.c @@ -32,7 +32,7 @@ #include #include "analyzer.h" #include "gl_usb.h" -#include "sigrok-internal.h" +#include "libsigrok-internal.h" enum { HARD_DATA_CHECK_SUM = 0x00, diff --git a/hardware/zeroplus-logic-cube/analyzer.h b/hardware/zeroplus-logic-cube/analyzer.h index 27722af7..d427c436 100644 --- a/hardware/zeroplus-logic-cube/analyzer.h +++ b/hardware/zeroplus-logic-cube/analyzer.h @@ -33,7 +33,7 @@ #define LIBSIGROK_HARDWARE_ZEROPLUS_LOGIC_CUBE_ANALYZER_H #include -#include "sigrok.h" +#include "libsigrok.h" #define STATUS_FLAG_NONE 0x00 #define STATUS_FLAG_RESET 0x01 diff --git a/hardware/zeroplus-logic-cube/gl_usb.c b/hardware/zeroplus-logic-cube/gl_usb.c index 52cafce8..6b894da9 100644 --- a/hardware/zeroplus-logic-cube/gl_usb.c +++ b/hardware/zeroplus-logic-cube/gl_usb.c @@ -31,8 +31,8 @@ #include #include -#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 | \ diff --git a/hardware/zeroplus-logic-cube/gl_usb.h b/hardware/zeroplus-logic-cube/gl_usb.h index 04a5163d..4d17a8fc 100644 --- a/hardware/zeroplus-logic-cube/gl_usb.h +++ b/hardware/zeroplus-logic-cube/gl_usb.h @@ -33,7 +33,7 @@ #define LIBSIGROK_HARDWARE_ZEROPLUS_LOGIC_CUBE_GL_USB_H #include -#include "sigrok.h" +#include "libsigrok.h" SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer, unsigned int size); diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 808b7053..627b937e 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -25,8 +25,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #include "analyzer.h" #define USB_VENDOR 0x0c12 diff --git a/hwdriver.c b/hwdriver.c index 185fa8c0..0fe7c703 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -23,8 +23,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" /* * This enumerates which driver capabilities correspond to user-settable diff --git a/input/binary.c b/input/binary.c index 4d6c4246..16081776 100644 --- a/input/binary.c +++ b/input/binary.c @@ -23,8 +23,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #define CHUNKSIZE (512 * 1024) #define DEFAULT_NUM_PROBES 8 diff --git a/input/chronovu_la8.c b/input/chronovu_la8.c index 79f83cc9..ceafd4db 100644 --- a/input/chronovu_la8.c +++ b/input/chronovu_la8.c @@ -22,8 +22,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" #define NUM_PACKETS 2048 #define PACKET_SIZE 4096 diff --git a/input/input.c b/input/input.c index f5e20a2f..06eb5117 100644 --- a/input/input.c +++ b/input/input.c @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#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; diff --git a/libsigrok-internal.h b/libsigrok-internal.h new file mode 100644 index 00000000..94ca2bc9 --- /dev/null +++ b/libsigrok-internal.h @@ -0,0 +1,133 @@ +/* + * This file is part of the sigrok project. + * + * Copyright (C) 2010-2012 Bert Vermeulen + * + * 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 . + */ + +#ifndef LIBSIGROK_SIGROK_INTERNAL_H +#define LIBSIGROK_SIGROK_INTERNAL_H + +#include +#include +#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ +#ifdef HAVE_LIBUSB_1_0 +#include +#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 diff --git a/libsigrok.h b/libsigrok.h new file mode 100644 index 00000000..2c0d6f96 --- /dev/null +++ b/libsigrok.h @@ -0,0 +1,499 @@ +/* + * This file is part of the sigrok project. + * + * Copyright (C) 2010-2012 Bert Vermeulen + * + * 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 . + */ + +#ifndef LIBSIGROK_SIGROK_H +#define LIBSIGROK_SIGROK_H + +#include +#include +#include +#include +#include + +#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: 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 diff --git a/log.c b/log.c index 3344d174..cc680473 100644 --- a/log.c +++ b/log.c @@ -20,8 +20,8 @@ #include #include -#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. */ diff --git a/output/binary.c b/output/binary.c index 6141b4ff..ef41dab4 100644 --- a/output/binary.c +++ b/output/binary.c @@ -21,8 +21,8 @@ #include #include #include -#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) diff --git a/output/chronovu_la8.c b/output/chronovu_la8.c index cca6a295..345a6545 100644 --- a/output/chronovu_la8.c +++ b/output/chronovu_la8.c @@ -21,8 +21,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { unsigned int num_enabled_probes; diff --git a/output/csv.c b/output/csv.c index 0f9f731a..6091711d 100644 --- a/output/csv.c +++ b/output/csv.c @@ -22,8 +22,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { unsigned int num_enabled_probes; diff --git a/output/float.c b/output/float.c index 850b5d43..e0622ceb 100644 --- a/output/float.c +++ b/output/float.c @@ -21,8 +21,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { unsigned int num_enabled_probes; diff --git a/output/gnuplot.c b/output/gnuplot.c index d57e6847..765f84eb 100644 --- a/output/gnuplot.c +++ b/output/gnuplot.c @@ -22,8 +22,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { unsigned int num_enabled_probes; diff --git a/output/ols.c b/output/ols.c index 0a55daf0..6ba384a9 100644 --- a/output/ols.c +++ b/output/ols.c @@ -28,8 +28,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { GString *header; diff --git a/output/output.c b/output/output.c index a7e26d9c..471ee9c7 100644 --- a/output/output.c +++ b/output/output.c @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#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; diff --git a/output/text/ascii.c b/output/text/ascii.c index dd4373f4..54d0e339 100644 --- a/output/text/ascii.c +++ b/output/text/ascii.c @@ -21,8 +21,8 @@ #include #include #include -#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) diff --git a/output/text/bits.c b/output/text/bits.c index 9692ac31..c1dbd2f8 100644 --- a/output/text/bits.c +++ b/output/text/bits.c @@ -21,8 +21,8 @@ #include #include #include -#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) diff --git a/output/text/hex.c b/output/text/hex.c index b0e20aa6..9477a7b5 100644 --- a/output/text/hex.c +++ b/output/text/hex.c @@ -21,8 +21,8 @@ #include #include #include -#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) diff --git a/output/text/text.c b/output/text/text.c index f0237a98..c4874321 100644 --- a/output/text/text.c +++ b/output/text/text.c @@ -23,8 +23,8 @@ #include #include #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) diff --git a/output/vcd.c b/output/vcd.c index 9f42f152..7f734279 100644 --- a/output/vcd.c +++ b/output/vcd.c @@ -23,8 +23,8 @@ #include #include #include "config.h" -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" struct context { int num_enabled_probes; diff --git a/proto.h b/proto.h new file mode 100644 index 00000000..3481c582 --- /dev/null +++ b/proto.h @@ -0,0 +1,138 @@ +/* + * This file is part of the sigrok project. + * + * Copyright (C) 2010-2012 Bert Vermeulen + * + * 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 . + */ + +#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 diff --git a/session.c b/session.c index 7c3dcef4..89ea5ad4 100644 --- a/session.c +++ b/session.c @@ -22,8 +22,8 @@ #include #include #include -#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]; diff --git a/session_driver.c b/session_driver.c index 301df7d2..ddcf0add 100644 --- a/session_driver.c +++ b/session_driver.c @@ -23,8 +23,8 @@ #include #include #include -#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) diff --git a/session_file.c b/session_file.c index d58d2f16..6b778162 100644 --- a/session_file.c +++ b/session_file.c @@ -24,8 +24,8 @@ #include #include #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; diff --git a/sigrok-internal.h b/sigrok-internal.h deleted file mode 100644 index 94ca2bc9..00000000 --- a/sigrok-internal.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of the sigrok project. - * - * Copyright (C) 2010-2012 Bert Vermeulen - * - * 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 . - */ - -#ifndef LIBSIGROK_SIGROK_INTERNAL_H -#define LIBSIGROK_SIGROK_INTERNAL_H - -#include -#include -#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ -#ifdef HAVE_LIBUSB_1_0 -#include -#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 diff --git a/sigrok-proto.h b/sigrok-proto.h deleted file mode 100644 index 3481c582..00000000 --- a/sigrok-proto.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is part of the sigrok project. - * - * Copyright (C) 2010-2012 Bert Vermeulen - * - * 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 . - */ - -#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 diff --git a/sigrok.h.in b/sigrok.h.in deleted file mode 100644 index 091eb3cf..00000000 --- a/sigrok.h.in +++ /dev/null @@ -1,530 +0,0 @@ -/* - * This file is part of the sigrok project. - * - * Copyright (C) 2010-2012 Bert Vermeulen - * - * 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 . - */ - -#ifndef LIBSIGROK_SIGROK_H -#define LIBSIGROK_SIGROK_H - -#include -#include -#include -#include -#include - -#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: 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 diff --git a/strutil.c b/strutil.c index f70a6f35..7c346a00 100644 --- a/strutil.c +++ b/strutil.c @@ -21,8 +21,8 @@ #include #include #include -#include "sigrok.h" -#include "sigrok-internal.h" +#include "libsigrok.h" +#include "libsigrok-internal.h" /** * Convert a numeric samplerate value to its "natural" string representation. diff --git a/version.c b/version.c index 77b9127a..be323dc6 100644 --- a/version.c +++ b/version.c @@ -18,7 +18,7 @@ * 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) { diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..b1a94f48 --- /dev/null +++ b/version.h.in @@ -0,0 +1,56 @@ +/* + * This file is part of the sigrok project. + * + * Copyright (C) 2010-2012 Bert Vermeulen + * + * 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 . + */ + +#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 +