1 unstable release
Uses new Rust 2024
| 0.1.0 | Jul 30, 2025 |
|---|
#4 in #instrument-control
Used in 2 crates
34KB
325 lines
InstrumentRs core library
This is the InstrumentRs core library, which provides the basic functionality to build Rust instrument drivers.
lib.rs:
InstrumentRs: Talk to your (scientific) equipment from with Rust
The InstrumentRs library provides standardized interfaces to talk to scientific equipment via
various different ports. To do so, it provides an InstrumentInterface trait and its
implementations. Furthermore, we also provide an InstrumentError error type that instrument
drivers should return. Any connection type that implements the std::io::Read and
std::io::Write traits can be used as an instrument interface. Furthermore, we also provide
simplified access to the following interfaces:
- TCP/IP (blocking) using the
std::netmodule. - Serial (blocking) using the
serialportcrate (feature"serial").
We are planning in the future to also support asynchronous interfaces.
Example
The following shows a simple example on how to get an Instrument interface using a simple
socket address.
use std::net::SocketAddr;
use instrumentrs::TcpIpInterface;
let address = "192.168.1.10:8000";
let inst_interface = TcpIpInterface::simple(address);
You can now take this instrument interface and pass it to any of the instrument drivers, of course assuming that the actual instrument is connected to this interface.
Goals and non-goals of this project
InstrumentRs shall provide a simple framework that allows you write your own instrument driver and share it with the community. It should allow you to focus on the driver design itself and take care of the interfacing for you. This allows your driver to be flexible, i.e., a serial device can be connected to a computer via RS232, but can also be connected via an ethernet to serial interface. InstrumentRs will take care of sending the correct commands for a specified instrument in the background.
While InstrumentRs is not a collection of drivers and only allows you to write a simplified
driver, we will host drivers here as well and maintain them. This means: If you would like to
write a driver but do not want to maintain it, please raise an issue in the InstrumentRs
repository on GitHub in order to get your driver added here. This means that we will take
over maintainership of the driver and release them as bugs get squished, etc. In order for this
to work, all functionality of your instrument driver must be tested with hardware, but also
with tests using the provided LoopbackInterface.
Inspiration
This project is heavily inspired by the fantastic
instrumentkit library that allows to
control instruments from Python.
Status
This project is currently under active development and (breaking) changes might occure fast. If you are interested in using this project and/or contributing, please get in touch by raising an issue on GitHub. This would also be super valuable as we would learn how it is used, what the need is, etc.
License
Licensed under either
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~0.2–11MB
~70K SLoC