{"id":43978952,"url":"https://github.com/gotmc/ivi","last_synced_at":"2026-02-07T08:35:18.582Z","repository":{"id":57505010,"uuid":"90194545","full_name":"gotmc/ivi","owner":"gotmc","description":"Go-based implementation of the Interchangeable Virtual Instrument (IVI) standard","archived":false,"fork":false,"pushed_at":"2025-08-13T02:22:24.000Z","size":1442,"stargazers_count":18,"open_issues_count":7,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T04:08:47.520Z","etag":null,"topics":["function-generator","gpib","instrument","instruments","ivi","ivi-drivers","ivi-specifications","ivi-standard","lxi","oscilloscope","power-supply","scpi","scpi-commands","spectrum-analyzer","tcpip","test-automation","test-equipment","usbtmc","virtual-instruments"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-03T21:23:03.000Z","updated_at":"2025-08-13T02:22:27.000Z","dependencies_parsed_at":"2022-09-19T09:50:49.754Z","dependency_job_id":"c1639288-9c04-4b7e-9cf1-97b35301059b","html_url":"https://github.com/gotmc/ivi","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/gotmc/ivi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotmc%2Fivi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotmc%2Fivi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotmc%2Fivi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotmc%2Fivi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotmc","download_url":"https://codeload.github.com/gotmc/ivi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotmc%2Fivi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29190294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["function-generator","gpib","instrument","instruments","ivi","ivi-drivers","ivi-specifications","ivi-standard","lxi","oscilloscope","power-supply","scpi","scpi-commands","spectrum-analyzer","tcpip","test-automation","test-equipment","usbtmc","virtual-instruments"],"created_at":"2026-02-07T08:35:17.936Z","updated_at":"2026-02-07T08:35:18.577Z","avatar_url":"https://github.com/gotmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ivi\n\nGo-based implementation of the Interchangeable Virtual Instrument (IVI)\nstandard.\n\n[![GoDoc][godoc badge]][godoc link]\n[![Go Report Card][report badge]][report card]\n[![License Badge][license badge]][LICENSE.txt]\n\n## Overview\n\nThe [IVI Specifications][ivi-specs] developed by the [IVI\nFoundation][ivi-foundation] provide standardized APIs for programming test\ninstruments. This package is a partial, Go-based implementation of the IVI\nSpecifications.\n\nThe main advantage of the [ivi][] package is not having to learn the [SCPI][]\ncommands for each individual piece of test equipment. For instance, by using the\n[ivi][] package both the Agilent 33220A and the Stanford Research Systems DS345\nfunction generators can be programmed using one standard API. The only\nrequirement for this is having an IVI driver for the desired test equipment.\n\nIf an [ivi][] driver doesn't exist for a peice of test equipment that you want\nto use, please open an issue and/or submit a pull request. The [IVI\nSpecifications][ivi-specs] don't provide APIs for every type of test equipment\n(e.g., they don't specify an API for electronic loads) in which case a set of\nAPIs will be developed as needed for new types of test equipment.\n\nDevelopment focus is currently on solidifying the APIs and creating a few IVI\ndrivers for each instrument type.\n\n### IVI Driver Goal\n\nPer Section 2.6 Capability Groups in IVI-3.1 Driver Architecture Specification:\n\n\u003e The fundamental goal of IVI drivers is to allow test developers to change the\n\u003e instrumentation hardware on their test systems without changing test program\n\u003e source code, recompiling, or re-linking. To achieve this goal, instrument\n\u003e drivers must have a standard programming interface...Because instruments do\n\u003e not have identical functionality or capability, it is impossible to create a\n\u003e single programming interface that covers all features of all instruments in a\n\u003e class. For this reason, the IVI Foundation recognizes different types of\n\u003e capabilities – Inherent Capabilities, Base Class Capabilities, Class Extension\n\u003e Capabilities and Instrument Specific Capabilities.\n\n### IVI Specification Deviation\n\n**TL;DR:** When developing the Go-based IVI drivers, follow the .NET methods and\nprototypes as much as possible.\n\nAs stated in Section 1.5 Conformance Requirements of the _IVI-3.1: Driver\nArchitecture Specification, Revision 3.8_, \"IVI drivers can be developed with a\nCOM, ANSI-C, or .NET API.\" In general, the Go method signatures try to be as\nclose to the .NET signatures as possible. However, given the desire to write\nidiomatic Go, where necessary and where it makes sense, the Go-based IVI drivers\ndeviate from the detailed [IVI Specifications][ivi-specs] at times.\n\nFor instance, since Go does not provide [method overloading][go-overload],\nthe .NET method prototypes cannot be followed in all cases. For example,\nin the IVI-4.2 IviDmm Class Specification, the .NET method prototypes show two\n`Configure` methods with different function signatures based on whether\nauto-range is specified or a manual range value is provided.\n\n```csharp\nvoid Configure(MeasurementFunction measurementFunction,\n               Auto autoRange,\n               Double resolution);\n\nvoid Configure(MeasurementFunction measurementFunction,\n               Double range,\u2028\n               Double resolution);\n```\n\nHowever, Go isn't C, so the Go-based IVI drivers don't have to rely on defined\nvalues, such as specific negative numbers representing auto-range (e.g., -1.0 =\nauto range on) and positive numbers representing the user specified manual\nrange. Using the same example, below is the C prototype for `Configure`, where\n`Range` is a `ViReal64` and negative values provided defined values.\n\n```c\nViStatus IviDmm_ConfigureMeasurement (ViSession Vi,\n                                      ViInt32 Function,\n                                      ViReal64 Range,\n                                      ViReal64 Resolution);\n```\n\nBecause of these differences, the Go function signatures may deviate from the\n[IVI Specifications][ivi-specs], when required and where it makes sense to\nenable writing idiomatic Go. Using the same example, below is the function\nsignature for `ConfigureMeasurement` in Go.\n\n```go\nConfigureMeasurement(\n    msrFunc MeasurementFunction,\n    autoRange AutoRange,\n    rangeValue float64,\n    resolution float64,\n) error\n```\n\n`MeasurementFunction` and `AutoRange` are user-defined types with [enumerated\nconstant][go-enums] values. Note: the function parameter `rangeValue` is used\ninstead of `range`, since `range` is a reserved keyword and cannot be used as an\nidentifier in Go.\n\n```go\ntype MeaurementFunction int\n\nconst (\n\tDCVolts MeasurementFunction = iota\n\tACVolts\n    ...\n\tPeriod\n\tTemperature\n)\n\ntype AutoRange int\n\nconst (\n\tAutoOn AutoRange = iota\n\tAutoOff\n\tAutoOnce\n)\n```\n\n## Installation\n\n```bash\n$ go get github.com/gotmc/ivi\n```\n\n## Usage\n\nThe [ivi][] package requires receiving an Instrument interface. The following\ngotmc packages meet the Instrument interface:\n\n- [visa][] — Calls [lxi][] or [usbtmc][] as needed, so that you can identify\n  instruments using a VISA resource address string.\n- [lxi][] — Used to control LXI enabled instruments via Ethernet.\n- [usbtmc][] — Used to control USBTMC compliant instruments via USB.\n- [prologix][] — Used to communicate with instruments using a Prologix GPIB\n  controller.\n- [asrl][] — Used to control intstruments via serial.\n\n## Examples\n\nExamples can be found at \u003chttps://github.com/gotmc/ivi-examples\u003e.\n\nFor timeout usage examples, see the [timeout examples](https://github.com/gotmc/ivi-examples/blob/master/timeout_example.md) in the ivi-examples repository.\n\n## Documentation\n\nDocumentation can be found at either:\n\n- \u003chttps://godoc.org/github.com/gotmc/ivi\u003e\n- \u003chttp://localhost:6060/pkg/github.com/gotmc/ivi/\u003e after running `$\ngodoc -http=:6060`\n\n## Timeout Support\n\nThe `ivi` package now provides comprehensive timeout support for instrument communications, addressing [Issue #3](https://github.com/gotmc/ivi/issues/3). This feature helps prevent hanging operations when instruments become unresponsive or network issues occur.\n\n### Basic Usage\n\n```go\n// Create an instrument with default timeout configuration\ninst := ivi.NewWithTimeout(baseInstrument, ivi.NewDefaultTimeoutConfig())\n\n// Create a driver with the timeout-wrapped instrument\ndmm, err := key3446x.New(inst, false)\n\n// All operations will now timeout if they take too long\nmanufacturer, err := dmm.InstrumentManufacturer()\nif err == context.DeadlineExceeded {\n    log.Println(\"Query timed out\")\n}\n```\n\n### Custom Timeout Configuration\n\n```go\n// Create custom timeout configuration\nconfig := \u0026ivi.TimeoutConfig{\n    IOTimeout:      5 * time.Second,   // For read/write operations\n    QueryTimeout:   10 * time.Second,  // For query operations (write + read)\n    CommandTimeout: 5 * time.Second,   // For command operations\n    ResetTimeout:   30 * time.Second,  // For reset operations\n    ClearTimeout:   5 * time.Second,   // For clear operations\n}\n\n// Wrap instrument with custom timeout configuration\ninst := ivi.NewWithTimeout(baseInstrument, config)\n```\n\n### Context-Based Timeouts\n\nFor fine-grained control over individual operations:\n\n```go\n// Create a context with a specific timeout\nctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)\ndefer cancel()\n\n// Use context-aware methods\nresponse, err := inst.QueryWithContext(ctx, \"*IDN?\")\n```\n\n### Setting Timeouts on Existing Drivers\n\n```go\n// Create a driver\ndmm, _ := key3446x.New(instrument, false)\n\n// Set a simple timeout for all operations\ndmm.SetTimeout(15 * time.Second)\n\n// Or set a custom timeout configuration\ndmm.SetTimeoutConfig(\u0026ivi.TimeoutConfig{\n    IOTimeout:    3 * time.Second,\n    QueryTimeout: 8 * time.Second,\n    // ... other timeout settings\n})\n```\n\nThe timeout feature is backward compatible---existing code will continue to work\nwithout modification. To enable timeouts, simply wrap your instrument with\n`ivi.NewWithTimeout()` when creating drivers.\n\nFor more detailed examples and advanced usage patterns, see the [timeout\nexamples](https://github.com/gotmc/ivi-examples/blob/master/timeout_example.md)\nin the ivi-examples repository.\n\n## Proper Cleanup and Local Control\n\nWhen working with instruments, it's important to properly clean up connections\nand optionally return instruments to local control so their front panels remain\noperational after your program ends.\n\n### Basic Cleanup Pattern\n\n```go\n// Create and use your instrument\ndmm, err := key3446x.New(inst, false)\nif err != nil {\n    log.Fatal(err)\n}\n\n// Always defer Close() to ensure proper cleanup\ndefer func() {\n    if err := dmm.Close(); err != nil {\n        log.Printf(\"Error during cleanup: %v\", err)\n    }\n}()\n\n// Use the instrument...\nmanufacturer, _ := dmm.InstrumentManufacturer()\n```\n\nBy default, `Close()` returns the instrument to local control (front panel\nregains control) before closing the connection.\n\n### Controlling Local Return Behavior\n\nYou can control whether the instrument returns to local control:\n\n```go\n// Disable automatic return to local control\ndmm.SetReturnToLocal(false)\n\n// Re-enable it later if needed\ndmm.SetReturnToLocal(true)\n\n// Check current setting\nif dmm.GetReturnToLocal() {\n    fmt.Println(\"Will return to local control on Close/Disable\")\n}\n```\n\n### Manual Local Control\n\nIf you need to return an instrument to local control without closing the\nconnection:\n\n```go\n// Return to local control (front panel regains control)\nerr := dmm.Disable()\nif err != nil {\n    log.Printf(\"Error returning to local: %v\", err)\n}\n```\n\n### Use Cases\n\n**Keep Remote Control** (set `ReturnToLocal` to false):\n\n- Automated test systems where instruments should stay in remote mode\n- Continuous monitoring applications\n- When switching between multiple controlling applications\n\n**Return to Local** (default, `ReturnToLocal` is true):\n\n- Development and debugging\n- Manual testing with occasional automation\n- Single-use scripts\n- Educational environments\n\n## Contributing\n\nContributions are welcome! To contribute please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Code\n4. Submit a [pull request][]\n\n### Testing\n\nPrior to submitting a [pull request][], please run:\n\n```bash\n$ make check\n$ make lint\n```\n\nTo update and view the test coverage report:\n\n```bash\n$ make cover\n```\n\n## License\n\n[ivi][] is released under the MIT license. Please see the\n[LICENSE.txt][] file for more information.\n\n[asrl]: https://github.com/gotmc/asrl\n[ivi]: https://github.com/gotmc/ivi\n[ivi-foundation]: http://www.ivifoundation.org/\n[ivi-specs]: http://www.ivifoundation.org/specifications/\n[go-enums]: https://go.dev/doc/effective_go#constants\n[go-overload]: https://go.dev/doc/faq#overloading\n[godoc badge]: https://godoc.org/github.com/gotmc/ivi?status.svg\n[godoc link]: https://godoc.org/github.com/gotmc/ivi\n[LICENSE.txt]: https://github.com/gotmc/ivi/blob/master/LICENSE.txt\n[license badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[lxi]: https://github.com/gotmc/lxi\n[prologix]: https://github.com/gotmc/prologix\n[pull request]: https://help.github.com/articles/using-pull-requests\n[report badge]: https://goreportcard.com/badge/github.com/gotmc/ivi\n[report card]: https://goreportcard.com/report/github.com/gotmc/ivi\n[scpi]: http://www.ivifoundation.org/scpi/\n[usbtmc]: https://github.com/gotmc/usbtmc\n[visa]: https://github.com/gotmc/visa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotmc%2Fivi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotmc%2Fivi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotmc%2Fivi/lists"}