Merge branch 'master' of git://sigrok.git.sourceforge.net/gitroot/sigrok/sigrok
This commit is contained in:
commit
2566bd4884
|
@ -38,7 +38,7 @@ libsigrok_la_LIBADD = \
|
||||||
input/libsigrokinput.la \
|
input/libsigrokinput.la \
|
||||||
output/libsigrokoutput.la
|
output/libsigrokoutput.la
|
||||||
|
|
||||||
include_HEADERS = sigrok.h
|
include_HEADERS = sigrok.h sigrok-proto.h
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = libsigrok.pc
|
pkgconfig_DATA = libsigrok.pc
|
||||||
|
|
|
@ -216,7 +216,7 @@ static int event(struct output *o, int event_type, char **data_out,
|
||||||
|
|
||||||
struct output_format output_analog = {
|
struct output_format output_analog = {
|
||||||
"analog",
|
"analog",
|
||||||
"Analog data",
|
"Analog data (takes argument, default 10)",
|
||||||
DF_ANALOG,
|
DF_ANALOG,
|
||||||
init,
|
init,
|
||||||
data,
|
data,
|
||||||
|
|
|
@ -306,7 +306,7 @@ static int data_hex(struct output *o, char *data_in, uint64_t length_in,
|
||||||
|
|
||||||
struct output_format output_text_bits = {
|
struct output_format output_text_bits = {
|
||||||
"bits",
|
"bits",
|
||||||
"Text (bits)",
|
"Bits (takes argument, default 64)",
|
||||||
DF_LOGIC,
|
DF_LOGIC,
|
||||||
init_bits,
|
init_bits,
|
||||||
data_bits,
|
data_bits,
|
||||||
|
@ -315,7 +315,7 @@ struct output_format output_text_bits = {
|
||||||
|
|
||||||
struct output_format output_text_hex = {
|
struct output_format output_text_hex = {
|
||||||
"hex",
|
"hex",
|
||||||
"Text (hexadecimal)",
|
"Hexadecimal (takes argument, default 256)",
|
||||||
DF_LOGIC,
|
DF_LOGIC,
|
||||||
init_hex,
|
init_hex,
|
||||||
data_hex,
|
data_hex,
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the sigrok project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 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 SIGROK_PROTO_H_
|
||||||
|
#define SIGROK_PROTO_H_
|
||||||
|
|
||||||
|
int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
|
||||||
|
char *data_in, uint64_t length_in, char **data_out,
|
||||||
|
uint64_t *length_out);
|
||||||
|
|
||||||
|
char *sigrok_samplerate_string(uint64_t samplerate);
|
||||||
|
char *sigrok_period_string(uint64_t frequency);
|
||||||
|
|
||||||
|
|
||||||
|
/*--- backend.c -------------------------------------------------------------*/
|
||||||
|
|
||||||
|
int sigrok_init(void);
|
||||||
|
void sigrok_cleanup(void);
|
||||||
|
|
||||||
|
/*--- debug.c ---------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void hexdump(unsigned char *address, int length);
|
||||||
|
|
||||||
|
struct input_format **input_list(void);
|
||||||
|
struct output_format **output_list(void);
|
||||||
|
|
||||||
|
void device_scan(void);
|
||||||
|
void device_close_all(void);
|
||||||
|
GSList *device_list(void);
|
||||||
|
struct device *device_new(struct device_plugin *plugin, int plugin_index, int num_probes);
|
||||||
|
void device_clear(struct device *device);
|
||||||
|
void device_destroy(struct device *dev);
|
||||||
|
|
||||||
|
void device_probe_clear(struct device *device, int probenum);
|
||||||
|
void device_probe_add(struct device *device, char *name);
|
||||||
|
struct probe *probe_find(struct device *device, int probenum);
|
||||||
|
void device_probe_name(struct device *device, int probenum, char *name);
|
||||||
|
|
||||||
|
void device_trigger_clear(struct device *device);
|
||||||
|
void device_trigger_set(struct device *device, int probenum, char *trigger);
|
||||||
|
|
||||||
|
int load_hwplugins(void);
|
||||||
|
GSList *list_hwplugins(void);
|
||||||
|
|
||||||
|
/* Generic device instances */
|
||||||
|
struct sigrok_device_instance *sigrok_device_instance_new(int index,
|
||||||
|
int status, const char *vendor, const char *model, const char *version);
|
||||||
|
struct sigrok_device_instance *get_sigrok_device_instance(
|
||||||
|
GSList *device_instances, int device_index);
|
||||||
|
void sigrok_device_instance_free(struct sigrok_device_instance *sdi);
|
||||||
|
|
||||||
|
/* USB-specific instances */
|
||||||
|
struct usb_device_instance *usb_device_instance_new(uint8_t bus,
|
||||||
|
uint8_t address, struct libusb_device_handle *hdl);
|
||||||
|
void usb_device_instance_free(struct usb_device_instance *usb);
|
||||||
|
|
||||||
|
/* Serial-specific instances */
|
||||||
|
struct serial_device_instance *serial_device_instance_new(
|
||||||
|
const char *port, int fd);
|
||||||
|
void serial_device_instance_free(struct serial_device_instance *serial);
|
||||||
|
|
||||||
|
int find_hwcap(int *capabilities, int hwcap);
|
||||||
|
struct hwcap_option *find_hwcap_option(int hwcap);
|
||||||
|
void source_remove(int fd);
|
||||||
|
void source_add(int fd, int events, int timeout, receive_data_callback rcv_cb,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
|
/*--- session.c -------------------------------------------------------------*/
|
||||||
|
|
||||||
|
typedef void (*source_callback_remove) (int fd);
|
||||||
|
typedef void (*source_callback_add) (int fd, int events, int timeout,
|
||||||
|
receive_data_callback callback, void *user_data);
|
||||||
|
typedef void (*datafeed_callback) (struct device *device,
|
||||||
|
struct datafeed_packet *packet);
|
||||||
|
|
||||||
|
/* Session setup */
|
||||||
|
struct session *session_load(const char *filename);
|
||||||
|
struct session *session_new(void);
|
||||||
|
void session_destroy(void);
|
||||||
|
void session_device_clear(void);
|
||||||
|
int session_device_add(struct device *device);
|
||||||
|
|
||||||
|
/* Protocol analyzers setup */
|
||||||
|
void session_pa_clear(void);
|
||||||
|
void session_pa_add(struct analyzer *pa);
|
||||||
|
|
||||||
|
/* Datafeed setup */
|
||||||
|
void session_datafeed_callback_clear(void);
|
||||||
|
void session_datafeed_callback_add(datafeed_callback callback);
|
||||||
|
|
||||||
|
/* Session control */
|
||||||
|
int session_start(void);
|
||||||
|
void session_stop(void);
|
||||||
|
void session_bus(struct device *device, struct datafeed_packet *packet);
|
||||||
|
void make_metadata(char *filename);
|
||||||
|
int session_save(char *filename);
|
||||||
|
|
||||||
|
/*--- hwcommon.c ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
|
||||||
|
int ezusb_install_firmware(libusb_device_handle *hdl, char *filename);
|
||||||
|
int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
||||||
|
const char *filename);
|
||||||
|
|
||||||
|
GSList *list_serial_ports(void);
|
||||||
|
int serial_open(const char *pathname, int flags);
|
||||||
|
int serial_close(int fd);
|
||||||
|
int serial_flush(int fd);
|
||||||
|
void *serial_backup_params(int fd);
|
||||||
|
void serial_restore_params(int fd, void *backup);
|
||||||
|
int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
|
||||||
|
int flowcontrol);
|
||||||
|
|
||||||
|
/* libsigrok/hardware/common/misc.c */
|
||||||
|
/* TODO: Should not be public. */
|
||||||
|
int opendev2(int device_index, struct sigrok_device_instance **sdi,
|
||||||
|
libusb_device *dev, struct libusb_device_descriptor *des,
|
||||||
|
int *skip, uint16_t vid, uint16_t pid, int interface);
|
||||||
|
int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev,
|
||||||
|
struct libusb_device_descriptor *des,
|
||||||
|
uint16_t vid, uint16_t pid, int interface);
|
||||||
|
|
||||||
|
/*--- datastore.c -----------------------------------------------------------*/
|
||||||
|
|
||||||
|
int datastore_new(int unitsize, struct datastore **ds);
|
||||||
|
int datastore_destroy(struct datastore *ds);
|
||||||
|
void datastore_put(struct datastore *ds, void *data, unsigned int length,
|
||||||
|
int in_unitsize, int *probelist);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SIGROK_PROTO_H_ */
|
156
sigrok.h
156
sigrok.h
|
@ -27,6 +27,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Status/error codes returned by libsigrok functions.
|
* Status/error codes returned by libsigrok functions.
|
||||||
*
|
*
|
||||||
|
@ -44,10 +45,10 @@
|
||||||
* or reused for different #defines later. You can only add new #defines and
|
* or reused for different #defines later. You can only add new #defines and
|
||||||
* return codes, but never remove or redefine existing ones.
|
* return codes, but never remove or redefine existing ones.
|
||||||
*/
|
*/
|
||||||
#define SIGROK_OK 0 /* No error */
|
#define SIGROK_OK 0 /* No error */
|
||||||
#define SIGROK_ERR -1 /* Generic/unspecified error */
|
#define SIGROK_ERR -1 /* Generic/unspecified error */
|
||||||
#define SIGROK_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
|
#define SIGROK_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
|
||||||
#define SIGROK_ERR_SAMPLERATE -3 /* Incorrect samplerate */
|
#define SIGROK_ERR_SAMPLERATE -3 /* Incorrect samplerate */
|
||||||
|
|
||||||
/* limited by uint64_t */
|
/* limited by uint64_t */
|
||||||
#define MAX_NUM_PROBES 64
|
#define MAX_NUM_PROBES 64
|
||||||
|
@ -69,7 +70,11 @@
|
||||||
#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
|
#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Data types, used by hardware plugins for set_configuration() */
|
|
||||||
|
typedef int (*receive_data_callback) (int fd, int revents, void *user_data);
|
||||||
|
|
||||||
|
|
||||||
|
/* Data types used by hardware plugins for set_configuration() */
|
||||||
enum {
|
enum {
|
||||||
T_UINT64,
|
T_UINT64,
|
||||||
T_CHAR,
|
T_CHAR,
|
||||||
|
@ -86,9 +91,7 @@ struct protocol {
|
||||||
int stackindex;
|
int stackindex;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Datafeed
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* datafeed_packet.type values */
|
/* datafeed_packet.type values */
|
||||||
enum {
|
enum {
|
||||||
|
@ -116,9 +119,8 @@ struct datafeed_header {
|
||||||
int num_logic_probes;
|
int num_logic_probes;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Input
|
|
||||||
*/
|
|
||||||
struct input {
|
struct input {
|
||||||
struct input_format *format;
|
struct input_format *format;
|
||||||
void *param;
|
void *param;
|
||||||
|
@ -132,12 +134,8 @@ struct input_format {
|
||||||
int (*in_loadfile) (const char *filename);
|
int (*in_loadfile) (const char *filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct input_format **input_list(void);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Output
|
|
||||||
*/
|
|
||||||
struct output {
|
struct output {
|
||||||
struct output_format *format;
|
struct output_format *format;
|
||||||
struct device *device;
|
struct device *device;
|
||||||
|
@ -156,17 +154,6 @@ struct output_format {
|
||||||
uint64_t *length_out);
|
uint64_t *length_out);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct output_format **output_list(void);
|
|
||||||
|
|
||||||
|
|
||||||
int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
|
|
||||||
char *data_in, uint64_t length_in, char **data_out,
|
|
||||||
uint64_t *length_out);
|
|
||||||
|
|
||||||
char *sigrok_samplerate_string(uint64_t samplerate);
|
|
||||||
char *sigrok_period_string(uint64_t frequency);
|
|
||||||
|
|
||||||
/*--- analyzer.c ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
struct analyzer {
|
struct analyzer {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -177,12 +164,6 @@ struct analyzer {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--- backend.c -------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int sigrok_init(void);
|
|
||||||
void sigrok_cleanup(void);
|
|
||||||
|
|
||||||
/*--- datastore.c -----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Size of a chunk in units */
|
/* Size of a chunk in units */
|
||||||
#define DATASTORE_CHUNKSIZE 512000
|
#define DATASTORE_CHUNKSIZE 512000
|
||||||
|
@ -194,16 +175,6 @@ struct datastore {
|
||||||
GSList *chunklist;
|
GSList *chunklist;
|
||||||
};
|
};
|
||||||
|
|
||||||
int datastore_new(int unitsize, struct datastore **ds);
|
|
||||||
int datastore_destroy(struct datastore *ds);
|
|
||||||
void datastore_put(struct datastore *ds, void *data, unsigned int length,
|
|
||||||
int in_unitsize, int *probelist);
|
|
||||||
|
|
||||||
/*--- debug.c ---------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void hexdump(unsigned char *address, int length);
|
|
||||||
|
|
||||||
/*--- device.c --------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This represents a generic device connected to the system.
|
* This represents a generic device connected to the system.
|
||||||
|
@ -237,22 +208,6 @@ struct probe {
|
||||||
|
|
||||||
extern GSList *devices;
|
extern GSList *devices;
|
||||||
|
|
||||||
void device_scan(void);
|
|
||||||
void device_close_all(void);
|
|
||||||
GSList *device_list(void);
|
|
||||||
struct device *device_new(struct device_plugin *plugin, int plugin_index, int num_probes);
|
|
||||||
void device_clear(struct device *device);
|
|
||||||
void device_destroy(struct device *dev);
|
|
||||||
|
|
||||||
void device_probe_clear(struct device *device, int probenum);
|
|
||||||
void device_probe_add(struct device *device, char *name);
|
|
||||||
struct probe *probe_find(struct device *device, int probenum);
|
|
||||||
void device_probe_name(struct device *device, int probenum, char *name);
|
|
||||||
|
|
||||||
void device_trigger_clear(struct device *device);
|
|
||||||
void device_trigger_set(struct device *device, int probenum, char *trigger);
|
|
||||||
|
|
||||||
/*--- hwplugin.c ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Hardware plugin capabilities */
|
/* Hardware plugin capabilities */
|
||||||
enum {
|
enum {
|
||||||
|
@ -272,6 +227,7 @@ struct hwcap_option {
|
||||||
char *shortname;
|
char *shortname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct sigrok_device_instance {
|
struct sigrok_device_instance {
|
||||||
int index;
|
int index;
|
||||||
int status;
|
int status;
|
||||||
|
@ -370,42 +326,6 @@ struct gsource_fd {
|
||||||
GSource *timeout_source;
|
GSource *timeout_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*receive_data_callback) (int fd, int revents, void *user_data);
|
|
||||||
|
|
||||||
int load_hwplugins(void);
|
|
||||||
GSList *list_hwplugins(void);
|
|
||||||
|
|
||||||
/* Generic device instances */
|
|
||||||
struct sigrok_device_instance *sigrok_device_instance_new(int index,
|
|
||||||
int status, const char *vendor, const char *model, const char *version);
|
|
||||||
struct sigrok_device_instance *get_sigrok_device_instance(
|
|
||||||
GSList *device_instances, int device_index);
|
|
||||||
void sigrok_device_instance_free(struct sigrok_device_instance *sdi);
|
|
||||||
|
|
||||||
/* USB-specific instances */
|
|
||||||
struct usb_device_instance *usb_device_instance_new(uint8_t bus,
|
|
||||||
uint8_t address, struct libusb_device_handle *hdl);
|
|
||||||
void usb_device_instance_free(struct usb_device_instance *usb);
|
|
||||||
|
|
||||||
/* Serial-specific instances */
|
|
||||||
struct serial_device_instance *serial_device_instance_new(
|
|
||||||
const char *port, int fd);
|
|
||||||
void serial_device_instance_free(struct serial_device_instance *serial);
|
|
||||||
|
|
||||||
int find_hwcap(int *capabilities, int hwcap);
|
|
||||||
struct hwcap_option *find_hwcap_option(int hwcap);
|
|
||||||
void source_remove(int fd);
|
|
||||||
void source_add(int fd, int events, int timeout, receive_data_callback rcv_cb,
|
|
||||||
void *user_data);
|
|
||||||
|
|
||||||
/*--- session.c -------------------------------------------------------------*/
|
|
||||||
|
|
||||||
typedef void (*source_callback_remove) (int fd);
|
|
||||||
typedef void (*source_callback_add) (int fd, int events, int timeout,
|
|
||||||
receive_data_callback callback, void *user_data);
|
|
||||||
typedef void (*datafeed_callback) (struct device *device,
|
|
||||||
struct datafeed_packet *packet);
|
|
||||||
|
|
||||||
struct session {
|
struct session {
|
||||||
/* List of struct device* */
|
/* List of struct device* */
|
||||||
GSList *devices;
|
GSList *devices;
|
||||||
|
@ -416,51 +336,5 @@ struct session {
|
||||||
GTimeVal starttime;
|
GTimeVal starttime;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Session setup */
|
#include "sigrok-proto.h"
|
||||||
struct session *session_load(const char *filename);
|
|
||||||
struct session *session_new(void);
|
|
||||||
void session_destroy(void);
|
|
||||||
void session_device_clear(void);
|
|
||||||
int session_device_add(struct device *device);
|
|
||||||
|
|
||||||
/* Protocol analyzers setup */
|
|
||||||
void session_pa_clear(void);
|
|
||||||
void session_pa_add(struct analyzer *pa);
|
|
||||||
|
|
||||||
/* Datafeed setup */
|
|
||||||
void session_datafeed_callback_clear(void);
|
|
||||||
void session_datafeed_callback_add(datafeed_callback callback);
|
|
||||||
|
|
||||||
/* Session control */
|
|
||||||
int session_start(void);
|
|
||||||
void session_stop(void);
|
|
||||||
void session_bus(struct device *device, struct datafeed_packet *packet);
|
|
||||||
void make_metadata(char *filename);
|
|
||||||
int session_save(char *filename);
|
|
||||||
|
|
||||||
/*--- hwcommon.c ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
|
|
||||||
int ezusb_install_firmware(libusb_device_handle *hdl, char *filename);
|
|
||||||
int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
|
||||||
const char *filename);
|
|
||||||
|
|
||||||
GSList *list_serial_ports(void);
|
|
||||||
int serial_open(const char *pathname, int flags);
|
|
||||||
int serial_close(int fd);
|
|
||||||
int serial_flush(int fd);
|
|
||||||
void *serial_backup_params(int fd);
|
|
||||||
void serial_restore_params(int fd, void *backup);
|
|
||||||
int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
|
|
||||||
int flowcontrol);
|
|
||||||
|
|
||||||
/* libsigrok/hardware/common/misc.c */
|
|
||||||
/* TODO: Should not be public. */
|
|
||||||
int opendev2(int device_index, struct sigrok_device_instance **sdi,
|
|
||||||
libusb_device *dev, struct libusb_device_descriptor *des,
|
|
||||||
int *skip, uint16_t vid, uint16_t pid, int interface);
|
|
||||||
int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev,
|
|
||||||
struct libusb_device_descriptor *des,
|
|
||||||
uint16_t vid, uint16_t pid, int interface);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue