2个版本

0.1.1 2023年8月22日
0.1.0 2023年8月11日

#1038 in 硬件支持

每月 32次下载
用于 instrument-ctl

自定义许可证

40KB
756

Rust USBTMC

用于连接仪器的USBTMC协议的纯Rust实现。

到目前为止,该库实现了基本的USBTMC控制端点命令,向BULK OUT端点写入DEVICE_DEPENDENT消息,并从BULK IN端点读取DEVICE_DEPENDENT消息。

用法

要使用它,请将以下行添加到您的项目Cargo.toml依赖项中

rs-usbtmc = "0.1"

示例

以下示例演示了如何连接到设备,向设备发送命令并查询设备。

use rs_usbtmc::UsbtmcClient;

const DEVICE_VID: u16 = 0x0000;
const DEVICE_PID: u16 = 0x0000;

fn main() {
    // connect to the device
    let device = UsbtmcClient::connect(DEVICE_VID, DEVICE_PID).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");
}

项目计划

我创建了这个驱动程序作为在暑期研究职位期间控制示波器项目的一部分。我单独无法访问示波器。如果我得到一个,计划是

  • 完全实现所有可能的请求
  • 实现usb488子类请求

我将联系我的大学以获取访问仪器的权限以完成此项目,但我愿意合作。

依赖关系

~1.6–2.4MB
~50K SLoC