#ascii #binary #serial #rs232 #zaber


A library from communicating with Zaber products in Rust

6 releases

0.3.2 Aug 4, 2023
0.3.1 Jun 16, 2023
0.3.0 May 22, 2023
0.2.1 May 24, 2022
0.1.1 Feb 26, 2022

#164 in Hardware support

Download history 20/week @ 2023-06-07 113/week @ 2023-06-14 35/week @ 2023-06-21 17/week @ 2023-06-28 5/week @ 2023-07-05 11/week @ 2023-07-12 90/week @ 2023-07-19 42/week @ 2023-07-26 42/week @ 2023-08-02 8/week @ 2023-08-09 9/week @ 2023-08-16 7/week @ 2023-08-30 26/week @ 2023-09-06 8/week @ 2023-09-13 10/week @ 2023-09-20

51 downloads per month

MIT license



A Rust implementation of Zaber's ASCII and Binary Protocols.

This library is unofficial. Zaber Motion Library is Zaber's official communications library, but as of this writing there are no Rust bindings.


Add this to your `Cargo.toml:

zproto = "0.3.2"

Getting started

This library aims to be simple but robust. Communicating with a product in Zaber's ASCII protocol looks something like this:

use zproto::{
    ascii::{Port, check, Warning},

fn main() -> Result<(), Error> {
    // Open the port, home device 1, and wait for it to finish.
    let mut port = Port::open_serial("/dev/ttyUSB0")?;
        (1, "home"),
        // Ignore warnings about it being unhomed.
        check::warning_in(("WR", "WH", Warning::NONE)),

    // Move towards the end of travel and monitor position as it goes.
    // Once the position exceeds 100000, interrupt the motion.
    port.command_reply((1, "move max"))?;
    port.poll_until((1, "get pos"), |reply| {
        let pos: i32 = reply.data().parse().unwrap();
        pos >= 100_000
    port.command_reply_with_check((1, "stop"), check::warning_is("NI"))?;

See the ascii or binary module documentation for a more in-depth introduction to communicating with devices using the Zaber ASCII or Binary protocols.

The examples folder has some simple applications.


The documentation is available on docs.rs.

Cargo Features

By default, both the ASCII and Binary protocols are enabled via the ascii and binary Cargo features, respectively. However, if you only want to use one, ascii for example, you can specify that in your Cargo.toml:

zproto = { version = "0.3.2", default-features = false, features = ["ascii"] }

This will only include portions of the library related to the ASCII protocol during compilation.


This project is license under the MIT License.


  1. Building fails with an error about libudev

    This crate requires the libudev shared library to be installed on your system, which some operating systems do not have installed by default. Installing the library will solve the problem. For example, on Ubuntu the library can be installed with sudo apt install libudev-dev.


~18K SLoC