Skip to content

WaveformData Fixes - #11

Open
jarom77 wants to merge 3 commits into
sgoadhouse:mainfrom
jarom77:waveform
Open

WaveformData Fixes#11
jarom77 wants to merge 3 commits into
sgoadhouse:mainfrom
jarom77:waveform

Conversation

@jarom77

@jarom77 jarom77 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

This fixes two errors in oscope_scpi/keysight.py:waveformData.

No Waveform Data

If there is no waveform data (scope hasn't been triggered yet, etc), WAVeform:PREamble? returns 22 values rather than 24. This causes the next line to throw an unhelpful error. While the error from the oscope is helpful, a ValueError exception is a mischaracterization of the error, so catching it doesn't make sense. I rewrote it to throw a BufferError instead (line 793-796) so it can be more intuitively caught and handled.

ERROR(00): 41,"Waveform data is not valid.", command: ':WAVeform:PREamble?'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "oscope_scpi/oscilloscope.py", line 329, in waveform
    (x, y, header, meta) = self.waveformData(channel, points)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "oscope_scpi/keysight.py", line 799, in waveformData
    (x, y, header, meta) = self._waveformDataNew(chan_str, points)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "oscope_scpi/keysight.py", line 401, in _waveformDataNew
    (wav_form, acq_type, wfmpts, avgcnt, x_increment, x_origin,
ValueError: not enough values to unpack (expected 24, got 22)

oscilloscope.py:waveform could also be rewritten to just return None or 0 on this error, but I felt preserving the exception provides better control to the user.

Channel Argument

waveformData says it takes channel as a string or None. When None is passed, we use self.channel, which isn't necessarily a string. Now it can take either a string or an integer because conversion happens within the function.

I also moved setting the waveform source to waveformData and out of the called functions _waveformDataNew and _waveformDataLegacy. It needs to be in waveformData in order to query the waveform completeness (line 794). We could leave setting this in the called functions, but it would be redundant.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant