daqhats-rs

Crates.iodaqhats-rs
lib.rsdaqhats-rs
version0.1.0
created_at2025-07-16 16:40:10.067974+00
updated_at2025-07-16 16:40:10.067974+00
descriptionRust bindings for the MCC DAQ HAT Library for Raspberry Pi data acquisition devices
homepagehttps://github.com/vincent-uden/daqhats-rs
repositoryhttps://github.com/vincent-uden/daqhats-rs
max_upload_size
id1755813
size594,967
Vincent Uden (vincent-uden)

documentation

https://docs.rs/daqhats-rs

README

daqhats-rs

Crates.io Documentation License

Rust bindings for the MCC DAQ HAT Library, providing access to Measurement Computing Corporation's data acquisition HAT devices for Raspberry Pi.

Supported Devices

  • MCC 118: 8-Channel Analog Input HAT
  • MCC 128: 8-Channel Analog Input HAT with thermocouple support
  • MCC 134: 4-Channel Thermocouple Input HAT
  • MCC 152: 2-Channel Analog Output / 8-Channel Digital I/O HAT
  • MCC 172: 2-Channel 24-bit Sigma-Delta A/D HAT

Platform Requirements

This library is designed for Raspberry Pi systems with MCC DAQ HAT hardware installed. The underlying C library requires:

  • Raspberry Pi OS (or compatible Linux distribution)
  • GPIO access and hardware drivers
  • libgpiod library

Installation

Add this to your Cargo.toml:

[dependencies]
daqhats-rs = "0.1"

Usage

use daqhats_rs::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // List all connected DAQ HATs
    let count = unsafe { hat_list(HatIDs_HAT_ID_ANY, std::ptr::null_mut()) };
    println!("Found {} DAQ HAT devices", count);

    if count > 0 {
        // Allocate memory for device info
        let mut devices = vec![HatInfo::default(); count as usize];
        unsafe {
            hat_list(HatIDs_HAT_ID_ANY, devices.as_mut_ptr());
        }

        for device in devices {
            println!("Device at address {}: ID = {}", device.address, device.id);
        }
    }

    Ok(())
}

Safety

This library provides direct bindings to the C library, so most functions are marked as unsafe. Users should:

Building

The library will automatically:

  1. Generate Rust bindings from C headers using bindgen
  2. On Raspberry Pi (ARM/AArch64): Compile the C library and link against it
  3. On other platforms: Generate bindings only (for development)

License

Licensed under either of:

at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Commit count: 0

cargo fmt