X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=libsigrok.h;h=2a88a7d03bc891602b404221ba661f9f918f4dd3;hb=fb480d578e423cd0f5702d1251e3cdccb990c9fb;hp=2c0d6f9648a6ee762c85fdf6703e11ee8320e6c0;hpb=45c59c8bdd01954f9214fe7b869d92c55415d109;p=libsigrok.git diff --git a/libsigrok.h b/libsigrok.h index 2c0d6f96..2a88a7d0 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -145,6 +145,7 @@ enum { SR_MQ_TEMPERATURE, SR_MQ_FREQUENCY, SR_MQ_DUTY_CYCLE, + SR_MQ_CONTINUITY, }; /* sr_datafeed_analog.unit values */ @@ -153,10 +154,34 @@ enum { SR_UNIT_AMPERE, SR_UNIT_OHM, SR_UNIT_FARAD, - SR_UNIT_CELSIUS, SR_UNIT_KELVIN, + SR_UNIT_CELSIUS, + SR_UNIT_FAHRENHEIT, SR_UNIT_HERTZ, SR_UNIT_PERCENTAGE, + SR_UNIT_BOOLEAN, +}; + +/** sr_datafeed_analog.flags values */ +enum { + /** Voltage measurement is alternating current. */ + SR_MQFLAG_AC = 0x01, + /** Voltage measurement is direct current. */ + SR_MQFLAG_DC = 0x02, + /** This is a true RMS measurement. */ + SR_MQFLAG_RMS = 0x04, + /** Value is voltage drop across a diode, or NAN. */ + SR_MQFLAG_DIODE = 0x08, + /** Device is in "hold" mode, i.e. repeating the last measurement. */ + SR_MQFLAG_HOLD = 0x10, + /** Device is in "max" mode, only updating when a new max value is found. */ + SR_MQFLAG_MAX = 0x20, + /** Device is in "min" mode, only updating when a new min value is found. */ + SR_MQFLAG_MIN = 0x40, + /** Device is in autoranging mode. */ + SR_MQFLAG_AUTORANGE = 0x80, + /** Device is in relative mode. */ + SR_MQFLAG_RELATIVE = 0x100, }; struct sr_datafeed_packet { @@ -186,15 +211,20 @@ struct sr_datafeed_meta_analog { 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. */ + /** Measured quantity (e.g. voltage, current, temperature) */ + int mq; + /** Unit in which the MQ is measured. */ + int unit; + /** Bitmap with extra information about the MQ. */ + uint64_t mqflags; float *data; }; struct sr_input { struct sr_input_format *format; - char *param; - struct sr_dev *vdev; + GHashTable *param; + struct sr_dev_inst *sdi; + void *internal; }; struct sr_input_format { @@ -207,7 +237,7 @@ struct sr_input_format { struct sr_output { struct sr_output_format *format; - struct sr_dev *dev; + struct sr_dev_inst *sdi; char *param; void *internal; }; @@ -222,6 +252,9 @@ struct sr_output_format { uint64_t *length_out); int (*event) (struct sr_output *o, int event_type, uint8_t **data_out, uint64_t *length_out); + GString *(*recv) (struct sr_output *o, const struct sr_dev_inst *sdi, + struct sr_datafeed_packet *packet); + int (*cleanup) (struct sr_output *o); }; struct sr_datastore { @@ -249,7 +282,8 @@ struct sr_dev { }; enum { - SR_PROBE_TYPE_LOGIC, + SR_PROBE_LOGIC, + SR_PROBE_ANALOG, }; struct sr_probe { @@ -260,7 +294,26 @@ struct sr_probe { char *trigger; }; -/* Hardware driver capabilities */ +struct sr_hwopt { + int hwopt; + const void *value; +}; + +/* Hardware driver options */ +enum { + SR_HWOPT_DUMMY = 0, /* Used to terminate lists. Must be 0! */ + + /** Some drivers cannot detect the exact model they're talking to. */ + SR_HWOPT_MODEL, + + /** Specification on how to connect to a device */ + SR_HWOPT_CONN, + + /** Serial communication spec: e.g. 8n1 */ + SR_HWOPT_SERIALCOMM, +}; + +/* Hardware device capabilities */ enum { SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */ @@ -279,26 +332,11 @@ enum { 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, @@ -336,6 +374,9 @@ enum { /*--- Special stuff -------------------------------------------------*/ + /** Session filename */ + SR_HWCAP_SESSIONFILE, + /* TODO: Better description. */ /** The device supports specifying a capturefile to inject. */ SR_HWCAP_CAPTUREFILE, @@ -386,12 +427,14 @@ struct sr_hwcap_option { }; struct sr_dev_inst { + struct sr_dev_driver *driver; int index; int status; int inst_type; char *vendor; char *model; char *version; + GSList *probes; void *priv; }; @@ -421,8 +464,10 @@ enum { /* Device info IDs */ enum { - /* struct sr_dev_inst for this specific device */ - SR_DI_INST, + /* A list of options supported by the driver. */ + SR_DI_HWOPTS, + /* A list of capabilities supported by the device. */ + SR_DI_HWCAPS, /* The number of probes connected to this device */ SR_DI_NUM_PROBES, /* The probe names on this device */ @@ -466,18 +511,31 @@ struct sr_dev_driver { char *name; char *longname; int api_version; - int (*init) (const char *devinfo); + int (*init) (void); int (*cleanup) (void); + GSList *(*scan) (GSList *options); + GSList *(*dev_list) (void); + int (*dev_clear) (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); + int (*dev_open) (struct sr_dev_inst *sdi); + int (*dev_close) (struct sr_dev_inst *sdi); + int (*info_get) (int info_id, const void **data, + const struct sr_dev_inst *sdi); + int (*dev_config_set) (const struct sr_dev_inst *sdi, int hwcap, + const void *value); + int (*dev_acquisition_start) (const struct sr_dev_inst *sdi, + void *cb_data); + int (*dev_acquisition_stop) (const struct sr_dev_inst *sdi, + void *cb_data); + + /* Dynamic */ + void *priv; +}; + +/* Private driver context. */ +struct drv_context { + GSList *instances; }; struct sr_session { @@ -486,7 +544,17 @@ struct sr_session { /* list of sr_receive_data_callback_t */ GSList *datafeed_callbacks; GTimeVal starttime; - gboolean running; + + unsigned int num_sources; + + /* Both "sources" and "pollfds" are of the same size and contain pairs of + * descriptor and callback function. We can not embed the GPollFD into the + * source struct since we want to be able to pass the array of all poll + * descriptors to g_poll. + */ + struct source *sources; + GPollFD *pollfds; + int source_timeout; }; #include "proto.h"