X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Frigol-ds%2Fprotocol.h;h=0117628ca04e72e6451d4b5680c670889db19497;hp=65b3d7eb1c895050e3057353b0c3328456e4afc6;hb=43cd4637285833706f8a404ca027bcf0ee75b9ae;hpb=0d87bd93eb5323b3bb325814a786efe3e336618d diff --git a/hardware/rigol-ds/protocol.h b/hardware/rigol-ds/protocol.h index 65b3d7eb..0117628c 100644 --- a/hardware/rigol-ds/protocol.h +++ b/hardware/rigol-ds/protocol.h @@ -28,30 +28,23 @@ #define LOG_PREFIX "rigol-ds" -#define DS1000_ANALOG_LIVE_WAVEFORM_SIZE 600 -#define DS2000_ANALOG_LIVE_WAVEFORM_SIZE 1400 -#define VS5000_ANALOG_LIVE_WAVEFORM_SIZE 2048 -/* Needs to be made configurable later */ -#define DS2000_ANALOG_MEM_WAVEFORM_SIZE_1C 14000 -#define DS2000_ANALOG_MEM_WAVEFORM_SIZE_2C 7000 -#define DIGITAL_WAVEFORM_SIZE 1210 /* Size of acquisition buffers */ #define ACQ_BUFFER_SIZE 32768 -enum rigol_ds_series { - RIGOL_DS1000, - RIGOL_DS1000Z, - RIGOL_DS2000, - RIGOL_DS4000, - RIGOL_DS6000, - RIGOL_VS5000, +#define MAX_ANALOG_CHANNELS 4 +#define MAX_DIGITAL_CHANNELS 16 + +enum protocol_version { + PROTOCOL_V1, /* VS5000 */ + PROTOCOL_V2, /* DS1000 */ + PROTOCOL_V3, /* DS2000, DSO1000 */ }; -enum rigol_protocol_flavor { - /* Used by DS1000 and VS5000 series */ - PROTOCOL_LEGACY, - /* Used by DS2000, DS4000, DS6000, ... series */ - PROTOCOL_IEEE488_2, +enum data_format { + /* Used by DS1000 versions up to 2.02, and VS5000 series */ + FORMAT_RAW, + /* Used by DS1000 versions from 2.04 onwards and all later series */ + FORMAT_IEEE488_2, }; enum data_source { @@ -60,15 +53,29 @@ enum data_source { DATA_SOURCE_SEGMENTED, }; -struct rigol_ds_model { - char *name; - enum rigol_ds_series series; - enum rigol_protocol_flavor protocol; - uint64_t min_timebase[2]; +struct rigol_ds_vendor { + const char *name; + const char *full_name; +}; + +struct rigol_ds_series { + const struct rigol_ds_vendor *vendor; + const char *name; + enum protocol_version protocol; + enum data_format format; uint64_t max_timebase[2]; uint64_t min_vdiv[2]; - bool has_digital; int num_horizontal_divs; + int live_samples; + int buffer_samples; +}; + +struct rigol_ds_model { + const struct rigol_ds_series *series; + const char *name; + uint64_t min_timebase[2]; + unsigned int analog_channels; + bool has_digital; }; enum wait_events { @@ -82,6 +89,7 @@ enum wait_events { struct dev_context { /* Device model */ const struct rigol_ds_model *model; + enum data_format format; /* Device properties */ const uint64_t (*timebases)[2]; @@ -89,38 +97,42 @@ struct dev_context { const uint64_t (*vdivs)[2]; uint64_t num_vdivs; - /* Probe groups */ - struct sr_probe_group analog_groups[2]; - struct sr_probe_group digital_group; + /* Channel groups */ + struct sr_channel_group analog_groups[MAX_ANALOG_CHANNELS]; + struct sr_channel_group digital_group; /* Acquisition settings */ - GSList *enabled_analog_probes; - GSList *enabled_digital_probes; + GSList *enabled_analog_channels; + GSList *enabled_digital_channels; uint64_t limit_frames; void *cb_data; enum data_source data_source; uint64_t analog_frame_size; + uint64_t digital_frame_size; /* Device settings */ - gboolean analog_channels[2]; - gboolean digital_channels[16]; + gboolean analog_channels[MAX_ANALOG_CHANNELS]; + gboolean digital_channels[MAX_DIGITAL_CHANNELS]; + gboolean la_enabled; float timebase; - float vdiv[2]; - int vert_reference[2]; - float vert_offset[2]; + float vdiv[MAX_ANALOG_CHANNELS]; + int vert_reference[MAX_ANALOG_CHANNELS]; + float vert_offset[MAX_ANALOG_CHANNELS]; char *trigger_source; float horiz_triggerpos; char *trigger_slope; - char *coupling[2]; + char *coupling[MAX_ANALOG_CHANNELS]; /* Operational state */ /* Number of frames received in total. */ uint64_t num_frames; - /* The channel we are currently receiving data for. */ - struct sr_probe *channel; - /* Number of samples received in current frame. */ - uint64_t num_frame_samples; + /* GSList entry for the current channel. */ + GSList *channel_entry; + /* Number of bytes received for current channel. */ + uint64_t num_channel_bytes; + /* Number of bytes of block header read */ + uint64_t num_header_bytes; /* Number of bytes in current data block, if 0 block header expected */ uint64_t num_block_bytes; /* Number of data block bytes already read */ @@ -134,7 +146,9 @@ struct dev_context { float *data; }; +SR_PRIV int rigol_ds_config_set(const struct sr_dev_inst *sdi, const char *format, ...); SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi); +SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi); SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data); SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi);