Skip to content

feat(instrodaq): unified read and write functions - #303

Open
maxleblang wants to merge 23 commits into
instro-524-sw-timed-background-daemonfrom
instro-501-unified-read-and-write
Open

feat(instrodaq): unified read and write functions#303
maxleblang wants to merge 23 commits into
instro-524-sw-timed-background-daemonfrom
instro-501-unified-read-and-write

Conversation

@maxleblang

@maxleblang maxleblang commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds unified read and write functions to InstroDAQ that route to either read_analog/digital or write_analog/digital depending on the type of channel it's operating on. This cleans up the surface a ton and makes reading and writing data with an InstroDAQ much easier.

Closes INSTRO-501

Type of change

  • Bug fix (fix)
  • New feature (feat)
  • Breaking change (feat! / fix!)
  • Refactor (refactor)
  • Documentation (docs)
  • Chore / tooling (chore)

Verification

ver 501

Tests

  • Unit tests added or updated
  • Existing tests cover this change
  • No tests — explain why:

Checklist

  • PR title follows Conventional Commits (e.g. feat(driver): add support for Keysight E36300)
  • I have read CONTRIBUTING.md
  • Documentation updated if user-facing behavior changed
  • Code follows the style/conventions of the surrounding code

Notes for reviewers

The new read() function wraps the existing read_analog() function that still raises an error when trying to read samples when the background daemon is running. We need to fix this functionality.

maxleblang and others added 11 commits July 23, 2026 15:00
Implement the branch's typed configure_* methods on _RecordingDriver and
migrate the unified read/write tests to the typed configure_*_input/output
HAL methods. Adds one-of-each analog input coverage to the read-all test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a scaler field to AnalogThermocoupleChannel and a scaler parameter to
configure_thermocouple_input, matching the voltage and current input types.
This also fixes an AttributeError in _scale_analog_measurement, which reads
ch_config.scaler on every AI channel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the scaler parameter to the configure_thermocouple_input signature in the
typed-configuration table, matching the voltage and current input entries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maxleblang
maxleblang requested review from hoehner and wharwood July 24, 2026 15:48
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds unified alias-based DAQ read and write operations.

  • Adds InstroDAQ.read() routing for analog inputs, digital lines, and digital ports.
  • Adds InstroDAQ.write() routing for analog outputs, digital lines, and digital ports.
  • Documents the unified API and adds unit coverage for routing, return values, and input validation.

Confidence Score: 5/5

The PR appears safe to merge with no blocking failures remaining.

No blocking failures remain after evaluating the changes against the previous review threads.

Important Files Changed

Filename Overview
instro/daq/daq.py Adds unified read/write dispatch while preserving requested alias order in read results.
tests/daq/test_daq_drivers.py Adds unit tests for unified analog and digital routing, scalar returns, and invalid inputs.
docs/guides/instrumentation/daq.mdx Documents unified reads and writes, examples, published channel names, and method references.

Reviews (2): Last reviewed commit: "Merge branch 'instro-500-explicit-input-..." | Re-trigger Greptile

Comment thread instro/daq/daq.py Outdated
Comment thread instro/daq/daq.py Outdated
Comment thread instro/daq/daq.py
measurement.channel_data[f"{self.name}.{ch_name}"] = scaled_values
return measurements

def read(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now have our read returning a dict instead of just a list of measurements. To me this is much more usable than having the user find their measurements in a list. Was there a reason we were just returning a list of measurements from read_analog()?

read() already rejected unknown input aliases before touching hardware;
write() checked each alias inside the dispatch loop, so a bad alias in a
multi-channel write raised only after earlier channels had already been
driven. Hoist the check to match read(), and cover both with a test that
asserts no driver I/O happened.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@maxleblang

Copy link
Copy Markdown
Contributor Author

Work for #223

Base automatically changed from instro-500-explicit-input-output-methods to main July 30, 2026 17:16
…unified-read-and-write

# Conflicts:
#	instro/daq/daq.py
#	tests/daq/test_daq_drivers.py
@mintlify

mintlify Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
instro 🟢 Ready View Preview Aug 4, 2026, 10:57 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@maxleblang
maxleblang changed the base branch from main to instro-524-sw-timed-background-daemon August 4, 2026 10:56
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