linux_gpib_rs/lib.rs
1//!
2//! Low-level wrapper for Linux GPIB.
3//!
4//! Documentation for the functions comes from [Linux GPIB Reference](https://linux-gpib.sourceforge.io/doc_html/reference.html).
5//! At the moment, only the 'Traditional' API Functions are wrapped.
6//!
7//! ## Requirements
8//!
9//! 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`,
10//! and for `libgpib.so` in either `/usr/lib` or `/usr/local/lib`.
11//!
12//!
13//! ## Example
14//!
15//! Add dependencies below to `Cargo.toml`
16//!
17//! ```toml
18//! linux-gpib-rs = { version = "0.1", features = ["async-tokio"] }
19//! ```
20//!
21//! Codes below will connect to the instrument on `GPIB0::1::INSTR` and print out its `*IDN?` response.
22//!
23//! **Synchronous example with Multidevice API**
24//!
25//! ```rust
26//! use linux_gpib_rs::instrument::Board;
27//! use linux_gpib_rs::types::IbSendEOI;
28//! use std::error::Error;
29//!
30//! fn main() -> Result<(), Box<dyn Error>> {
31//! let board = Board::with_board_number(0);
32//! let instruments = board.find_listeners()?;
33//! board.send_list(&instruments, b"*IDN?\n", IbSendEOI::default())?;
34//! for instr in instruments {
35//! let iden = instr.receive()?;
36//! println!("{:>20} {}", instr.visa_string(), iden.trim());
37//! }
38//! Ok(())
39//! }
40//! ```
41//!
42//! **Asynchronous example**
43//!
44//! Same thing with asynchronous API.
45//!
46//! ```rust
47//! use linux_gpib_rs::instrument::{Parameters, Board};
48//! use linux_gpib_rs::error::GpibError;
49//! use tokio::task::JoinSet;
50//! use std::error::Error;
51//!
52//! #[tokio::main]
53//! async fn main() -> Result<(), Box<dyn Error>> {
54//! let board = Board::with_board_number(0);
55//! let instruments = board.find_listeners()?;
56//! let mut set = JoinSet::<Result<(String, String), GpibError>>::new();
57//! for instr in instruments {
58//! let handle = instr.open(Parameters::default())?;
59//! let visa_string = instr.visa_string();
60//! set.spawn(async move {
61//! let iden = handle.query("*IDN?\n").await?;
62//! Ok((visa_string, iden))
63//! });
64//! }
65//! while let Some(Ok(val)) = set.join_next().await {
66//! if let Ok((visa_string, iden)) = val {
67//! println!("{:>20} {}", visa_string, iden.trim());
68//! }
69//! }
70//! Ok(())
71//! }
72//! ```
73
74pub mod error;
75pub mod instrument;
76pub mod lowlevel;
77pub mod status;
78pub mod types;
79
80const DEBUG: bool = false;