Skip to content

[Instruments] WaveformFormat.RIGOL_WORD value accessor reads bytes, not 16-bit words — WORD waveforms render garbage #1037

Description

@ammaree

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions