Skip to content

vikansys/LinuxGPIB.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


LinuxGPIB.Net

NuGet Version Target Framework Platform License: GPL v3

LinuxGPIB.Net is a modern .NET 8+ wrapper for the linux-gpib 4.3.7 C library, providing safe, high-level abstractions for communicating with GPIB instruments on Linux.

  • High-level API (no P/Invoke required)
  • Thread-safe device coordination via GpibDeviceManager
  • Synchronous and asynchronous operations
  • Tested with linux-gpib 4.3.7
  • Licensed under GPLv3 or later

Installation

1. Install the NuGet package

dotnet add package LinuxGPIB.Net

2. Install linux-gpib (version 4.3.7)

LinuxGPIB.Net requires the native linux-gpib library to be installed on the system.

A installation guide for linux-gpib 4.3.4 can be found here: http://elektronomikon.org/install.html

The guide is still applicable for linux-gpib 4.3.7. Replace the version-specific steps with the sequence below:

wget https://github.com/coolshou/linux-gpib/archive/refs/tags/4.3.7.tar.gz
tar -xzf 4.3.7.tar.gz

cd linux-gpib-4.3.7/linux-gpib-user/
./configure
make
make install
ldconfig

cd ../linux-gpib-kernel/
make
make install

Depending on your GPIB hardware, you may need to load the appropriate kernel module (e.g., xyphro_ugc, gpib_bitbang, etc.).


Quick Start

Basic usage through the high-level GpibDevice class:

using LinuxGPIB.Net;

var dev = new GpibDevice(primaryAddress: 5);

dev.Write("*IDN?");
string idn = dev.Read();

Console.WriteLine(idn);

Query helper

string idn = dev.Query("*IDN?");

Configuration Example

var dev = new GpibDevice(
    primaryAddress: 5,
    timeout: GpibTimeout.T3s,
    boardIndex: 0,
    eot: 1,
    eos: 0);

Asynchronous Polling

await dev.QueryAsync("*IDN?");              // Wait for MAV
await dev.WaitForMessageAsync();           // Wait for MAV
await dev.WaitForServiceRequestAsync();    // Wait for SRQ

Thread-Safe Device Access

Use GpibDeviceManager to serialize calls per instrument and automatically dispose idle devices.

using LinuxGPIB.Net;
using LinuxGPIB.Net.Management;

var manager = new GpibDeviceManager();
var address = new GpibAddress(5);

string idn = await manager.ExecuteAsync(address, async dev =>
{
    dev.Write("*IDN?");
    return dev.Read();
});

Device Discovery

var bus = new GpibBus();
var devices = bus.DiscoverDevices();

Features

  • High-level wrapper around linux-gpib
  • Automatic cleanup of idle devices
  • Read, write, and query support
  • Serial polling (MAV and SRQ)
  • Asynchronous wait operations
  • Device discovery utilities

Requirements

  • Linux platform
  • linux-gpib 4.3.7
  • .NET 8.0+

Tested hardware

This library has been tested on real hardware with:

Other GPIB instruments should work, but have not been explicitly tested.


License

LinuxGPIB.Net is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

See the LICENSE file for details.


About

A modern .NET 8 wrapper for the linux-gpib library.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages