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