From: Martin Ling Date: Fri, 17 Jan 2014 02:56:01 +0000 (+0000) Subject: rigol-ds: Correct digital waveform block sizes. X-Git-Tag: libsigrok-0.3.0~239 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d22250a96adbef6dbae44cd8e346cb5f31a3f872;p=libsigrok.git rigol-ds: Correct digital waveform block sizes. --- diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index 63c6e225..44847c71 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -489,6 +489,20 @@ static int analog_frame_size(const struct sr_dev_inst *sdi) } } +static int digital_frame_size(const struct sr_dev_inst *sdi) +{ + struct dev_context *devc = sdi->priv; + + switch (devc->model->series) { + case RIGOL_VS5000: + return VS5000_DIGITAL_WAVEFORM_SIZE; + case RIGOL_DS1000: + return DS1000_DIGITAL_WAVEFORM_SIZE; + default: + return 0; + } +} + static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_probe_group *probe_group) { @@ -875,6 +889,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->channel_entry = devc->enabled_digital_probes; devc->analog_frame_size = analog_frame_size(sdi); + devc->digital_frame_size = digital_frame_size(sdi); if (devc->model->protocol == PROTOCOL_LEGACY) { /* Fetch the first frame. */ diff --git a/hardware/rigol-ds/protocol.c b/hardware/rigol-ds/protocol.c index 0dc36cf4..9b2dd68d 100644 --- a/hardware/rigol-ds/protocol.c +++ b/hardware/rigol-ds/protocol.c @@ -477,10 +477,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) devc->num_block_bytes = len; } else { devc->num_block_bytes = probe->type == SR_PROBE_ANALOG ? - (devc->model->series == RIGOL_VS5000 ? - VS5000_ANALOG_LIVE_WAVEFORM_SIZE : - DS1000_ANALOG_LIVE_WAVEFORM_SIZE) : - DIGITAL_WAVEFORM_SIZE; + devc->analog_frame_size : devc->digital_frame_size; } devc->num_block_read = 0; } @@ -553,7 +550,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) devc->num_frame_samples += len; if (devc->num_frame_samples < (probe->type == SR_PROBE_ANALOG ? - devc->analog_frame_size : DIGITAL_WAVEFORM_SIZE)) + devc->analog_frame_size : devc->digital_frame_size)) /* Don't have the whole frame yet. */ return TRUE; diff --git a/hardware/rigol-ds/protocol.h b/hardware/rigol-ds/protocol.h index e19ac490..f19bf75b 100644 --- a/hardware/rigol-ds/protocol.h +++ b/hardware/rigol-ds/protocol.h @@ -28,14 +28,18 @@ #define LOG_PREFIX "rigol-ds" +/* Analog waveform block sizes */ #define DS1000_ANALOG_LIVE_WAVEFORM_SIZE 600 #define DS2000_ANALOG_LIVE_WAVEFORM_SIZE 1400 #define VS5000_ANALOG_LIVE_WAVEFORM_SIZE 2048 #define DSO1000_ANALOG_LIVE_WAVEFORM_SIZE 600 -/* 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 + +/* Digital waveform block size */ +#define DS1000_DIGITAL_WAVEFORM_SIZE 1200 +#define VS5000_DIGITAL_WAVEFORM_SIZE 4096 + /* Size of acquisition buffers */ #define ACQ_BUFFER_SIZE 32768 @@ -107,6 +111,7 @@ struct dev_context { void *cb_data; enum data_source data_source; uint64_t analog_frame_size; + uint64_t digital_frame_size; /* Device settings */ gboolean analog_channels[MAX_ANALOG_PROBES];