Summary
initValuesAccesor() in packages/eez-studio-ui/chart/value-accesor.ts
handles WaveformFormat.RIGOL_WORD with a correct length calculation but
a byte-oriented data accessor, so any waveform stored in RIGOL WORD
format renders as garbage (the first half of the buffer interpreted as
8-bit samples).
The code
} else if (format === WaveformFormat.RIGOL_WORD) {
length = Math.floor(values.length / 2); // correct: 2 bytes per point
waveformData = (index: number) => {
return values[index]; // BUG: reads ONE byte at `index`,
}; // not a 16-bit word at 2*index
value = (index: number) => {
return offset + waveformData(index) * scale;
};
}
Compare RIGOL_BYTE directly above it — the accessor body is identical.
For WORD it should assemble two bytes per point, e.g. (little-endian):
waveformData = (index: number) => {
return values[2 * index] | (values[2 * index + 1] << 8);
};
Why it matters
Rigol's current 12-bit scope generations (DHO800/DHO900/MHO900) only
deliver their full resolution via :WAVeform:FORMat WORD — BYTE
transfers quantize to 8 bits. Extension scripts that try to store
12-bit-faithful waveforms with session.addChart({format: RIGOL_WORD})
get corrupted rendering, and currently have to work around it by
converting to FLOATS in script (doubling memory).
Found while building IEXT extensions for the Rigol MHO98 / DHO924S
(12-bit). Related context: none of the official extensions appear to use
RIGOL_WORD (the official Rigol family scripts use BYTE), which is
presumably why this hasn't surfaced before.
Environment
- EEZ Studio 0.29.0 (code present on master at time of filing)
Summary
initValuesAccesor()inpackages/eez-studio-ui/chart/value-accesor.tshandles
WaveformFormat.RIGOL_WORDwith a correct length calculation buta byte-oriented data accessor, so any waveform stored in RIGOL WORD
format renders as garbage (the first half of the buffer interpreted as
8-bit samples).
The code
Compare
RIGOL_BYTEdirectly above it — the accessor body is identical.For WORD it should assemble two bytes per point, e.g. (little-endian):
Why it matters
Rigol's current 12-bit scope generations (DHO800/DHO900/MHO900) only
deliver their full resolution via
:WAVeform:FORMat WORD— BYTEtransfers quantize to 8 bits. Extension scripts that try to store
12-bit-faithful waveforms with
session.addChart({format: RIGOL_WORD})get corrupted rendering, and currently have to work around it by
converting to FLOATS in script (doubling memory).
Found while building IEXT extensions for the Rigol MHO98 / DHO924S
(12-bit). Related context: none of the official extensions appear to use
RIGOL_WORD (the official Rigol family scripts use BYTE), which is
presumably why this hasn't surfaced before.
Environment