Pure Rust implementation of the USBTMC protocol to connect to instruments.
Thus far, this library implements the basic USBTMC control endpoint commands, writing DEVICEDEPENDENT messages to the BULK OUT endpoint and reading DEVICEDEPENDENT messages to the BULK IN endpoint.
To use, add the following line to your project's Cargo.toml dependencies:
toml
rs-usbtmc = "0.1"
The example below demonstrates how to connect to, send commands to and query the device.
```rust use rs_usbtmc::UsbtmcClient;
const DEVICEVID: u16 = 0x0000; const DEVICEPID: u16 = 0x0000;
fn main() { // connect to the device let device = UsbtmcClient::connect(DEVICEVID, DEVICEPID).expect("failed to connect");
// send a command to the device
device.command("*IDN?").expect("failed to send command");
// query the device and get a string
let response: String = device.query("*IDN?").expect("failed to query device");
// query the device and get a bytes
let response: Vec<u8> = device.query_raw("*IDN?").expect("failed to query device");
} ```
I created this driver as part of a project to control an oscilloscope during a summer research position. Alone, I do not have access to an oscilloscope. If I do obtain one, the plan is to:
I'll reach out to my university for access to an instrument to complete this project, but I'm open to collaborating.