Crate linux_gpib_rs

Source
Expand description

Low-level wrapper for Linux GPIB.

Documentation for the functions comes from Linux GPIB Reference. At the moment, only the ‘Traditional’ API Functions are wrapped.

§Requirements

This crate needs to link to an installed linux-gpib user library. It will look for gpib/ib.h in either /usr/include or /usr/local/include, and for libgpib.so in either /usr/lib or /usr/local/lib.

§Example

Add dependencies below to Cargo.toml

linux-gpib-rs = { version = "0.1", features = ["async-tokio"] }

Codes below will connect to the instrument on GPIB0::1::INSTR and print out its *IDN? response.

Synchronous example

We can use the low-level synchronous functions ibrd and ibwrt.

use linux_gpib_rs::{
    OpenParam,
    open,
    ibwrt,
    ibrd,
};
use std::error::Error;
 
fn main() -> Result<(), Box<dyn Error>> {
    let ud = open("GPIB0::1::INSTR", OpenParam::default())?;
    ibwrt(ud, b"*IDN?\r\n")?;
    let mut buffer: [u8; 256] = [0; 256];
    ibrd(ud, &mut buffer)?;
    let iden = String::from_utf8(buffer.to_vec())?;
    println!("{iden}");
    Ok(())
}

Asynchronous example

We can use slightly higher-level asynchronous functions write and read (based on ibrda and ibwrta). This requires the async-tokio feature.

use linux_gpib_rs::{open, write, read, OpenParam};
use std::error::Error;
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let ud = open("GPIB0::1::INSTR", OpenParam::default())?;
    write(ud, "*IDN?\r\n").await?;
    let iden = read(ud).await?;
    println!("{iden}");
    Ok(())
}

Structs§

IbEosMode
IbLineStatus
IbStatus
OpenParam
PrimaryAddress
SecondaryAddress

Enums§

GpibError
IbError
IbEvent
IbOnline
IbOption
IbSendEOI
IbTimeout

Functions§

ibask
ibask – query configuration (board or device) See: Linux GPIB Reference
ibbna
ibbna – change access board (device) See: Linux GPIB Reference
ibcac
ibcac – assert ATN (board) See: Linux GPIB Reference
ibclr
ibclr – clear device (device) See: Linux GPIB Reference
ibcmd
ibcmd – write command bytes (board) See: Linux GPIB Reference
ibconfig
ibconfig – change configuration (board or device) See: Linux GPIB Reference
ibdev
ibdev – open a device (device) See: Linux GPIB Reference
ibeos
ibeos – set end-of-string mode (board or device) See: Linux GPIB Reference
ibeot
ibeot – assert EOI with last data byte (board or device) See: Linux GPIB Reference
ibevent
ibevent – get events from event queue (board) See: Linux GPIB Reference
ibfind
ibfind – open a board or device (board or device) See: Linux GPIB Reference
ibgts
ibgts – release ATN (board) See: Linux GPIB Reference
ibist
ibist – set individual status bit (board) See: Linux GPIB Reference
iblines
iblines – monitor bus lines (board) See: Linux GPIB Reference
ibln
ibln – check if listener is present (board or device) See: Linux GPIB Reference
ibloc
ibloc – go to local mode (board or device) See: Linux GPIB Reference
ibonl
ibonl – close or reinitialize descriptor (board or device) See: Linux GPIB Reference
ibpad
ibpad – set primary GPIB address (board or device) See: Linux GPIB Reference
ibpct
ibpct – pass control (board) See: Linux GPIB Reference
ibppc
ibppc – parallel poll configure (board or device) See: Linux GPIB Reference
ibrd
ibrd – read data bytes (board or device) See: Linux GPIB Reference
ibrdf
ibrdf – read data bytes to file (board or device) See: Linux GPIB Reference
ibrpp
ibrpp – perform a parallel poll (board or device) See: Linux GPIB Reference
ibrsc
ibrsc – request system control (board) See: Linux GPIB Reference
ibrsp
ibrsp – read status byte / serial poll (device) See: Linux GPIB Reference
ibrsv
ibrsv – request service (board) See: Linux GPIB Reference
ibrsv2
ibrsv2 – request service (board) See: Linux GPIB Reference
ibsad
ibsad – set secondary GPIB address (board or device) See: Linux GPIB Reference
ibsic
ibsic – perform interface clear (board) See: Linux GPIB Reference
ibspb
ibspb – obtain length of serial poll bytes queue (device) See: Linux GPIB Reference
ibsre
ibsre – set remote enable (board) See: Linux GPIB Reference
ibstop
ibstop – abort asynchronous i/o operation (board or device) See: Linux GPIB Reference
ibtmo
ibtmo – adjust io timeout (board or device) See: Linux GPIB Reference
ibtrg
ibtrg – trigger device (device) See: Linux GPIB Reference
ibvers
ibvers – Obtain the current linux gpib version See: Linux GPIB Reference
ibwait
ibwait – wait for event (board or device) See: Linux GPIB Reference
ibwrt
ibwrt – write data bytes (board or device) See: Linux GPIB Reference
ibwrtf
ibwrtf – write data bytes from file (board or device) See: Linux GPIB Reference
open
Quickly open a device from a VISA-style address, e.g. ‘GPIB0::1::INSTR’.
read
wait
write