Skip to content

Add Windows compatibility (serialport v12), OSR control, and cycler log interval#1

Open
joeltroughton wants to merge 3 commits into
dansteingart:mainfrom
joeltroughton:main
Open

Add Windows compatibility (serialport v12), OSR control, and cycler log interval#1
joeltroughton wants to merge 3 commits into
dansteingart:mainfrom
joeltroughton:main

Conversation

@joeltroughton

Copy link
Copy Markdown

Summary

  • Upgrade serialport from v9 to v12 for Windows compatibility: v9 relied on nan for native bindings which was problematic on Windows, v12 uses node-addon-api with prebuilt binaries. Updated import syntax, constructor signature, and baud rate fallback to match the v12 API.

  • Add OSR (Oversampling Rate) control: New set_osr(ch, osr) SCPI command function and POST /smu/set_osr REST endpoint
    with validation (0–15 range).

  • Add cycler data log interval throttling: Decouples disk write frequency from streaming sample rate to prevent enormous log files at high sample rates. New POST /cycler/set_log_interval endpoint (default 10s, minimum 100ms). WebSocket streaming and in-memory data are unaffected.

  • Fix SMU settling race condition — add 200ms delay between enable_channel() and setpoint commands (set_current/set_potential) in CC/CV cycler modes to allow hardware to initialize before receiving setpoint

Details on serialport v12 changes

Aspect v9 (Upstream) v12 (This PR)
Import const SerialPort = require('serialport') const { SerialPort } = require('serialport')
Constructor new SerialPort(path, { baudRate }) new SerialPort({ path, baudRate })
Baud fallback undefined 115200 (required by v12 constructor)
Native bindings nan + prebuild-install node-addon-api + node-gyp-build
Min Node.js >=10.0.0 >=16.0.0

Introduce configurable logging interval and SMU OSR support, plus upgrade to serialport v12.

Details:
- Add a logging interval mechanism (cyclerState.logIntervalMs, lastLogTime) to throttle SQLite/CSV writes and a new POST /cycler/set_log_interval endpoint to adjust it.
- Add SMU OSR tracking and control: smuState.channels[].osr, set_osr() helper and POST /smu/set_osr route with validation.
- Add a small 200ms settle delay after enabling a channel before issuing set_current/set_potential to improve SMU stability.
- Improve CC voltage cutoff logging and add debug output to aid troubleshooting.
- Make serial port usage compatible with serialport v12: change import to { SerialPort }, adjust constructor to SerialPort({ path, baudRate }), and add a default baud fallback of 115200.
- package.json and package-lock.json updated to bump serialport to ^12.0.0 (lockfile updated accordingly).

These changes reduce excessive IO load during high-frequency streaming, add OSR control, improve SMU command timing, and update the serial driver dependency.
Add prerequisites and platform-specific examples (Linux/macOS and Windows) and clarify SERIAL_PORT usage. Document new API endpoints for measurement oversampling (POST /smu/set_osr) and cycler log throttling (POST /cycler/set_log_interval) with curl examples and explanation of log interval behavior. Include guidance on log interval throttling to reduce disk writes while preserving WebSocket/in-memory streaming. Update README dependency listing to reflect serialport ^12.0.0.
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