You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reuse bufio.Reader, fix examples, and fix lint issues
Store a single *bufio.Reader on Controller instead of allocating one per
Query/QueryController call, avoiding repeated allocations and potential
buffered data loss. Fix examples to use updated query.Bool API and
non-constant format strings. Fix misspelling and unchecked error return
flagged by linter. Reformat long lines with golines.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
Go package for communicating with Prologix GPIB-USB and GPIB-ETHERNET controllers, which bridge a computer to GPIB (IEEE 488) test instruments. Part of the [gotmc](https://github.com/gotmc) ecosystem and designed to work with the [ivi](https://github.com/gotmc/ivi) package for standardized instrument control.
7
+
Go package for communicating with Prologix GPIB-USB and GPIB-ETHERNET controllers, which bridge a computer to GPIB (IEEE 488) test instruments. Part of the [gotmc](https://github.com/gotmc) ecosystem and designed to work with the [ivi](https://github.com/gotmc/ivi) package for standardized instrument control. Requires Go 1.25+.
8
8
9
9
## Build & Test Commands
10
10
@@ -23,6 +23,8 @@ go test -run TestIsPrimaryAddressValid ./...
23
23
24
24
# HTML coverage report
25
25
just cover
26
+
27
+
# Run example (requires hardware): just key3631 /dev/ttyUSB0 5
26
28
```
27
29
28
30
`just` (Justfile) is the task runner; there is no Makefile.
@@ -34,13 +36,14 @@ The package uses a layered design separating transport from GPIB protocol logic:
34
36
-**Transport layer** (`driver/`): Provides `io.ReadWriter` implementations for different connection types. Currently only `driver/vcp/` (Virtual COM Port via serial) is implemented. The `driver/usb/` and `driver/net/` directories are placeholders for future D2XX and Ethernet support.
35
37
-**Controller** (`controller.go`): Core type wrapping any `io.ReadWriter`. Constructed via `NewController()` with functional options (`WithSecondaryAddress`, `WithDebug`, `WithAR488`). Handles GPIB address setup, controller initialization commands, and the `++` command prefix for Prologix-specific commands.
36
38
-**Commands** (`commands.go`): Methods on `Controller` for Prologix `++` commands (e.g., `ClearDevice`, `SetReadTimeout`, `Version`, `InstrumentAddress`).
39
+
-**Examples** (`examples/vcp/`): Working examples for real instruments (E3631A, DS345, Fluke 45, 33220A). All follow the same pattern: open VCP → create Controller → query version → run device commands → restore front panel → close.
37
40
38
41
Key design points:
39
42
-`Controller` distinguishes between instrument communication (`Command`, `Query`, `Write`) and Prologix controller commands (`CommandController`, `QueryController`) which prepend `++`.
40
43
- Context-aware I/O: `Controller` checks if the underlying `io.ReadWriter` implements optional `ContextReader`/`ContextWriter` interfaces. If so, it delegates directly; otherwise it falls back to goroutine-based context handling.
41
44
- The `WithAR488()` option skips `verbose` and `savecfg` commands for Arduino AR488 compatibility.
42
45
-`Query` automatically sends `++read eoi` when auto read-after-write is disabled.
43
-
- Binary data methods (`Write`/`Read`) vs string methods (`WriteString`, `Command`, `Query`) handle GPIB character escaping differently.
46
+
- Binary data methods (`Write`/`Read`) vs string methods (`WriteString`, `Command`, `Query`) handle GPIB character escaping differently. Prologix strips unescaped LF, CR, ESC, and `+` characters, so `Write` escapes them automatically.
44
47
- VCP serial config is hardcoded to Prologix defaults: 115200 baud, 7 data bits, even parity, 1 stop bit.
0 commit comments