Crate daqhats_rs

Source
Expand description

§daqhats-rs

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

This library provides safe Rust bindings to the C library for MCC DAQ HAT devices including:

  • 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 Support

This library is designed to work on Raspberry Pi systems with the appropriate MCC DAQ HAT hardware installed. The underlying C library requires GPIO access and specific hardware drivers that are only available on Raspberry Pi.

§Usage

use daqhats_rs::*;

// List all connected DAQ HATs
let count = unsafe { hat_list(HatIDs_HAT_ID_ANY as u16, std::ptr::null_mut()) };
println!("Found {} DAQ HAT devices", count);

// Check for MCC 118 devices specifically
let mcc118_count = unsafe { hat_list(HatIDs_HAT_ID_MCC_118 as u16, std::ptr::null_mut()) };
if mcc118_count > 0 {
    println!("Found {} MCC 118 devices", mcc118_count);
}

§Safety

This library provides direct bindings to the C library, so most functions are marked as unsafe. Users should be familiar with the MCC DAQ HAT C library documentation and ensure proper error handling when using these functions.

Structs§

HatInfo
Contains information about a specific board.
MCC118DeviceInfo
MCC 118 constant device information.
MCC128DeviceInfo
MCC 128 constant device information.
MCC134DeviceInfo
MCC 134 constant device information.
MCC152DeviceInfo
MCC 152 constant device information.
MCC172DeviceInfo
MCC 172 constant device information.
__fsid_t

Constants§

A_IN_MODE_BIT_MASK
A_IN_MODE_BIT_POS
A_IN_MODE_DIFF_FLAG
A_IN_MODE_SE_FLAG
A_IN_RANGE_BIP_1V_FLAG
A_IN_RANGE_BIP_2V_FLAG
A_IN_RANGE_BIP_5V_FLAG
A_IN_RANGE_BIP_10V_FLAG
A_IN_RANGE_BIT_MASK
A_IN_RANGE_BIT_POS
AnalogInputMode_A_IN_MODE_DIFF
Differential
AnalogInputMode_A_IN_MODE_SE
Single-ended
AnalogInputRange_A_IN_RANGE_BIP_1V
+/- 1 V
AnalogInputRange_A_IN_RANGE_BIP_2V
+/- 2 V
AnalogInputRange_A_IN_RANGE_BIP_5V
+/- 5 V
AnalogInputRange_A_IN_RANGE_BIP_10V
+/- 10 V
COMMON_MODE_TC_VALUE
DIOConfigItem_DIO_DIRECTION
Configure channel direction
DIOConfigItem_DIO_INPUT_INVERT
Configure input inversion
DIOConfigItem_DIO_INPUT_LATCH
Configure input latching
DIOConfigItem_DIO_INT_MASK
Configure interrupt mask
DIOConfigItem_DIO_OUTPUT_TYPE
Configure output type
DIOConfigItem_DIO_PULL_CONFIG
Configure pull-up/down resistor
DIOConfigItem_DIO_PULL_ENABLE
Enable pull-up/down resistor
HatIDs_HAT_ID_ANY
Match any DAQ HAT ID in hat_list()(@ref hat_list)
HatIDs_HAT_ID_MCC_118
MCC 118 ID
HatIDs_HAT_ID_MCC_128
MCC 128 ID
HatIDs_HAT_ID_MCC_134
MCC 134 ID
HatIDs_HAT_ID_MCC_152
MCC 152 ID
HatIDs_HAT_ID_MCC_172
MCC 172 ID
HatIDs_HAT_ID_MCC_118_BOOTLOADER
MCC 118 in firmware update mode ID
INT8_MAX
INT8_MIN
INT16_MAX
INT16_MIN
INT32_MAX
INT32_MIN
INTPTR_MAX
INTPTR_MIN
INT_FAST8_MAX
INT_FAST8_MIN
INT_FAST16_MAX
INT_FAST16_MIN
INT_FAST32_MAX
INT_FAST32_MIN
INT_LEAST8_MAX
INT_LEAST8_MIN
INT_LEAST16_MAX
INT_LEAST16_MIN
INT_LEAST32_MAX
INT_LEAST32_MIN
MAX_NUMBER_HATS
OPEN_TC_VALUE
OPTS_CONTINUOUS
OPTS_DEFAULT
OPTS_EXTCLOCK
OPTS_EXTTRIGGER
OPTS_NOCALIBRATEDATA
OPTS_NOSCALEDATA
OVERRANGE_TC_VALUE
PTRDIFF_MAX
PTRDIFF_MIN
ResultCode_RESULT_BAD_PARAMETER
A parameter passed to the function was incorrect.
ResultCode_RESULT_BUSY
The device is busy.
ResultCode_RESULT_COMMS_FAILURE
Could not communicate with the device.
ResultCode_RESULT_INVALID_DEVICE
The device at the specified address is not the correct type.
ResultCode_RESULT_LOCK_TIMEOUT
There was a timeout while obtaining a resource lock.
ResultCode_RESULT_RESOURCE_UNAVAIL
A needed resource was not available.
ResultCode_RESULT_SUCCESS
Success, no errors
ResultCode_RESULT_TIMEOUT
There was a timeout accessing a resource.
ResultCode_RESULT_UNDEFINED
Some other error occurred.
SIG_ATOMIC_MAX
SIG_ATOMIC_MIN
SIZE_MAX
STATUS_BUFFER_OVERRUN
STATUS_HW_OVERRUN
STATUS_RUNNING
STATUS_TRIGGERED
SourceType_SOURCE_LOCAL
Use a local-only source.
SourceType_SOURCE_MASTER
Use a local source and set it as master.
SourceType_SOURCE_SLAVE
Use a separate master source.
TcTypes_TC_DISABLED
Input disabled
TcTypes_TC_TYPE_B
B type
TcTypes_TC_TYPE_E
E type
TcTypes_TC_TYPE_J
J type
TcTypes_TC_TYPE_K
K type
TcTypes_TC_TYPE_N
N type
TcTypes_TC_TYPE_R
R type
TcTypes_TC_TYPE_S
S type
TcTypes_TC_TYPE_T
T type
TriggerMode_TRIG_ACTIVE_HIGH
Start the scan any time TRIG is high.
TriggerMode_TRIG_ACTIVE_LOW
Start the scan any time TRIG is low.
TriggerMode_TRIG_FALLING_EDGE
Start the scan on a falling edge of TRIG.
TriggerMode_TRIG_RISING_EDGE
Start the scan on a rising edge of TRIG.
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINTPTR_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
WINT_MAX
WINT_MIN
_ATFILE_SOURCE
_BITS_STDINT_INTN_H
_BITS_STDINT_LEAST_H
_BITS_STDINT_UINTN_H
_BITS_TIME64_H
_BITS_TYPESIZES_H
_BITS_TYPES_H
_BITS_WCHAR_H
_DEFAULT_SOURCE
_FEATURES_H
_POSIX_C_SOURCE
_POSIX_SOURCE
_STDC_PREDEF_H
_STDINT_H
_SYS_CDEFS_H
__FD_SETSIZE
__GLIBC_MINOR__
__GLIBC_USE_C2X_STRTOL
__GLIBC_USE_DEPRECATED_GETS
__GLIBC_USE_DEPRECATED_SCANF
__GLIBC_USE_IEC_60559_BFP_EXT
__GLIBC_USE_IEC_60559_BFP_EXT_C2X
__GLIBC_USE_IEC_60559_EXT
__GLIBC_USE_IEC_60559_FUNCS_EXT
__GLIBC_USE_IEC_60559_FUNCS_EXT_C2X
__GLIBC_USE_IEC_60559_TYPES_EXT
__GLIBC_USE_ISOC2X
__GLIBC_USE_LIB_EXT2
__GLIBC__
__GNU_LIBRARY__
__HAVE_GENERIC_SELECTION
__INO_T_MATCHES_INO64_T
__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI
__OFF_T_MATCHES_OFF64_T
__RLIM_T_MATCHES_RLIM64_T
__STATFS_MATCHES_STATFS64
__STDC_IEC_559_COMPLEX__
__STDC_IEC_559__
__STDC_IEC_60559_BFP__
__STDC_IEC_60559_COMPLEX__
__STDC_ISO_10646__
__SYSCALL_WORDSIZE
__TIMESIZE
__USE_ATFILE
__USE_FORTIFY_LEVEL
__USE_ISOC11
__USE_ISOC95
__USE_ISOC99
__USE_MISC
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_POSIX_IMPLICITLY
__USE_XOPEN2K
__USE_XOPEN2K8
__WORDSIZE
__WORDSIZE_TIME64_COMPAT32
__glibc_c99_flexarr_available

Functions§

check_result
Convert a C result code to a Rust Result
error_message
Get a human-readable error message for a result code (fallback for non-ARM systems)
hat_error_message
Return a text description for a DAQ HAT result code.
hat_interrupt_callback_disable
Disable interrupt callbacks.
hat_interrupt_callback_enable
Enable an interrupt callback function.
hat_interrupt_state
Read the current interrupt status.
hat_list
Return a list of detected DAQ HAT boards.
hat_wait_for_interrupt
Wait for an interrupt to occur.
mcc118_a_in_read
@brief Perform a single reading of an analog input channel and return the value.
mcc118_a_in_scan_actual_rate
@brief Read the actual sample rate per channel for a requested sample rate.
mcc118_a_in_scan_buffer_size
@brief Returns the size of the internal scan data buffer.
mcc118_a_in_scan_channel_count
@brief Return the number of channels in the current analog input scan.
mcc118_a_in_scan_cleanup
@brief Free analog input scan resources after the scan is complete.
mcc118_a_in_scan_read
@brief Reads status and multiple samples from an analog input scan.
mcc118_a_in_scan_start
@brief Start a hardware-paced analog input scan.
mcc118_a_in_scan_status
@brief Reads status and number of available samples from an analog input scan.
mcc118_a_in_scan_stop
@brief Stops an analog input scan.
mcc118_blink_led
@brief Blink the LED on the MCC 118.
mcc118_calibration_coefficient_read
@brief Read the MCC 118 calibration coefficients for a single channel.
mcc118_calibration_coefficient_write
@brief Temporarily write the MCC 118 calibration coefficients for a single channel.
mcc118_calibration_date
@brief Read the MCC 118 calibration date
mcc118_close
@brief Close a connection to an MCC 118 device and free allocated resources.
mcc118_firmware_version
@brief Return the board firmware and bootloader versions.
mcc118_info
@brief Return constant device information for all MCC 118s.
mcc118_is_open
@brief Check if an MCC 118 is open.
mcc118_open
@brief Open a connection to the MCC 118 device at the specified address.
mcc118_serial
@brief Read the MCC 118 serial number
mcc118_test_clock
@brief Test the CLK pin.
mcc118_test_trigger
@brief Test the TRIG pin by returning the current state.
mcc118_trigger_mode
@brief Set the trigger input mode.
mcc128_a_in_mode_read
@brief Read the analog input mode.
mcc128_a_in_mode_write
@brief Set the analog input mode.
mcc128_a_in_range_read
@brief Read the analog input range.
mcc128_a_in_range_write
@brief Set the analog input range.
mcc128_a_in_read
@brief Perform a single reading of an analog input channel and return the value.
mcc128_a_in_scan_actual_rate
@brief Read the actual sample rate per channel for a requested sample rate.
mcc128_a_in_scan_buffer_size
@brief Returns the size of the internal scan data buffer.
mcc128_a_in_scan_channel_count
@brief Return the number of channels in the current analog input scan.
mcc128_a_in_scan_cleanup
@brief Free analog input scan resources after the scan is complete.
mcc128_a_in_scan_queue_start
mcc128_a_in_scan_read
@brief Reads status and multiple samples from an analog input scan.
mcc128_a_in_scan_start
@brief Start a hardware-paced analog input scan.
mcc128_a_in_scan_status
@brief Reads status and number of available samples from an analog input scan.
mcc128_a_in_scan_stop
@brief Stops an analog input scan.
mcc128_blink_led
@brief Blink the LED on the MCC 128.
mcc128_calibration_coefficient_read
@brief Read the MCC 128 calibration coefficients for a specified input range.
mcc128_calibration_coefficient_write
@brief Temporarily write the MCC 128 calibration coefficients for a specified input range.
mcc128_calibration_date
@brief Read the MCC 128 calibration date
mcc128_close
@brief Close a connection to an MCC 128 device and free allocated resources.
mcc128_firmware_version
@brief Return the board firmware version.
mcc128_info
@brief Return constant device information for all MCC 128s.
mcc128_is_open
@brief Check if an MCC 128 is open.
mcc128_open
@brief Open a connection to the MCC 128 device at the specified address.
mcc128_serial
@brief Read the MCC 128 serial number
mcc128_test_clock
@brief Test the CLK pin.
mcc128_test_trigger
@brief Test the TRIG pin by returning the current state.
mcc128_trigger_mode
@brief Set the trigger input mode.
mcc134_a_in_read
@brief Read an analog input channel and return the value.
mcc134_calibration_coefficient_read
@brief Read the MCC 134 calibration coefficients for a single channel.
mcc134_calibration_coefficient_write
@brief Temporarily write the MCC 134 calibration coefficients for a single channel.
mcc134_calibration_date
@brief Read the MCC 134 calibration date
mcc134_cjc_read
@brief Read the cold junction compensation temperature for a specified channel.
mcc134_close
@brief Close a connection to an MCC 134 device and free allocated resources.
mcc134_info
@brief Return constant device information for all MCC 134s.
mcc134_is_open
@brief Check if an MCC 134 is open.
mcc134_open
@brief Open a connection to the MCC 134 device at the specified address.
mcc134_serial
@brief Read the MCC 134 serial number
mcc134_t_in_read
@brief Read a temperature input channel.
mcc134_tc_type_read
@brief Read the thermocouple type for a channel.
mcc134_tc_type_write
@brief Write the thermocouple type for a channel.
mcc134_update_interval_read
@brief Read the temperature update interval.
mcc134_update_interval_write
@brief Write the temperature update interval.
mcc152_a_out_write
@brief Perform a write to an analog output channel.
mcc152_a_out_write_all
@brief Perform a write to all analog output channels simultaneously.
mcc152_close
@brief Close a connection to an MCC 152 device and free allocated resources.
mcc152_dio_config_read_bit
@brief Read a digital I/O configuration value for a single channel.
mcc152_dio_config_read_port
@brief Read a digital I/O configuration value for all channels.
mcc152_dio_config_write_bit
@brief Write a digital I/O configuration value for a single channel.
mcc152_dio_config_write_port
@brief Write a digital I/O configuration value for all channels.
mcc152_dio_input_read_bit
@brief Read a single digital input channel.
mcc152_dio_input_read_port
@brief Read all digital input channels simultaneously.
mcc152_dio_int_status_read_bit
@brief Read the interrupt status for a single channel.
mcc152_dio_int_status_read_port
@brief Read the interrupt status for all channels.
mcc152_dio_output_read_bit
@brief Read a single digital output register.
mcc152_dio_output_read_port
@brief Read all digital output registers simultaneously.
mcc152_dio_output_write_bit
@brief Write a single digital output channel.
mcc152_dio_output_write_port
@brief Write all digital output channels simultaneously.
mcc152_dio_reset
@brief Reset the digital I/O to the default configuration.
mcc152_info
@brief Return constant device information for all MCC 152s.
mcc152_is_open
@brief Check if an MCC 152 is open.
mcc152_open
@brief Open a connection to the MCC 152 device at the specified address.
mcc152_serial
@brief Read the MCC 152 serial number
mcc172_a_in_clock_config_read
@brief Read the sampling clock configuration.
mcc172_a_in_clock_config_write
@brief Write the sampling clock configuration.
mcc172_a_in_scan_buffer_size
@brief Returns the size of the internal scan data buffer.
mcc172_a_in_scan_channel_count
@brief Return the number of channels in the current analog input scan.
mcc172_a_in_scan_cleanup
@brief Free analog input scan resources after the scan is complete.
mcc172_a_in_scan_read
@brief Reads status and multiple samples from an analog input scan.
mcc172_a_in_scan_start
@brief Start capturing analog input data from the specified channels
mcc172_a_in_scan_status
@brief Reads status and number of available samples from an analog input scan.
mcc172_a_in_scan_stop
@brief Stops an analog input scan.
mcc172_a_in_sensitivity_read
@brief Read the MCC 172 analog input sensitivity scaling factor for a single channel.
mcc172_a_in_sensitivity_write
@brief Write the MCC 172 analog input sensitivity scaling factor for a single channel.
mcc172_blink_led
@brief Blink the LED on the MCC 172.
mcc172_calibration_coefficient_read
@brief Read the MCC 172 calibration coefficients for a single channel.
mcc172_calibration_coefficient_write
@brief Temporarily write the MCC 172 calibration coefficients for a single channel.
mcc172_calibration_date
@brief Read the MCC 172 calibration date
mcc172_close
@brief Close a connection to an MCC 172 device and free allocated resources.
mcc172_firmware_version
@brief Return the board firmware version.
mcc172_iepe_config_read
@brief Read the MCC 172 IEPE configuration for a single channel.
mcc172_iepe_config_write
@brief Write the MCC 172 IEPE configuration for a single channel.
mcc172_info
@brief Return constant device information for all MCC 172s.
mcc172_is_open
@brief Check if an MCC 172 is open.
mcc172_open
@brief Open a connection to the MCC 172 device at the specified address.
mcc172_serial
@brief Read the MCC 172 serial number
mcc172_test_signals_read
@brief Read the state of shared signals for testing.
mcc172_test_signals_write
@brief Write values to shared signals for testing.
mcc172_trigger_config
@brief Configure the digital trigger.

Type Aliases§

AnalogInputMode
Analog input modes.
AnalogInputRange
Analog input ranges
DIOConfigItem
DIO Configuration Items
DaqResult
Result type for DAQ HAT operations
HatIDs
Known DAQ HAT IDs.
ResultCode
Return values from the library functions.
SourceType
Clock / trigger source definitions.
TcTypes
Thermocouple type constants
TriggerMode
Scan trigger input modes.
__blkcnt64_t
__blkcnt_t
__blksize_t
__caddr_t
__clock_t
__clockid_t
__daddr_t
__dev_t
__fsblkcnt64_t
__fsblkcnt_t
__fsfilcnt64_t
__fsfilcnt_t
__fsword_t
__gid_t
__id_t
__ino64_t
__ino_t
__int8_t
__int16_t
__int32_t
__int64_t
__int_least8_t
__int_least16_t
__int_least32_t
__int_least64_t
__intmax_t
__intptr_t
__key_t
__loff_t
__mode_t
__nlink_t
__off64_t
__off_t
__pid_t
__quad_t
__rlim64_t
__rlim_t
__sig_atomic_t
__socklen_t
__ssize_t
__suseconds64_t
__suseconds_t
__syscall_slong_t
__syscall_ulong_t
__time_t
__timer_t
__u_char
__u_int
__u_long
__u_quad_t
__u_short
__uid_t
__uint8_t
__uint16_t
__uint32_t
__uint64_t
__uint_least8_t
__uint_least16_t
__uint_least32_t
__uint_least64_t
__uintmax_t
__useconds_t
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
int_least8_t
int_least16_t
int_least32_t
int_least64_t
intmax_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
uintmax_t