Skip to main content

Crate hart_link

Crate hart_link 

Source
Expand description

Tools for communicating with HART devices.

The architecture separates wire-byte representation, operation semantics, and exchange execution. Core types and the streaming decoder are available without the standard library. The asynchronous queue and network channels are enabled by the runtime feature.

§Hardware validation status

Wired HART communication has been exercised with real devices through a transparent Moxa TCP gateway and directly through a USB HART modem. The wireless-hart feature is covered by software tests but has not yet been exercised against real WirelessHART radios and Network Managers. See the mesh module for the reporting format and safety requirements for dumps.

§Minimal wire example

use hart_link::{Address, Master, Request, inspect_bytes};

let address = Address::polling(0, Master::Primary)?;
let bytes = Request::new(address, 0u8, vec![]).to_frame()?.encode()?;
let report = inspect_bytes(&bytes).map_err(|issue| issue.message)?;
assert_eq!(report.command.get(), 0);

§Application-defined queues

Runtime users define one or more independently bounded queues. Weighted queues rotate without starvation; strict queues explicitly precede weighted traffic.

use hart_link::{QueueConfig, QueueId, QueuePriority};

const CONTROL: QueueId = QueueId::new(10);
const POLLING: QueueId = QueueId::new(20);
let queues = [
    QueueConfig::strict(CONTROL, 32, 10)?,
    QueueConfig::weighted(POLLING, 256, 1)?,
];
assert_eq!(queues[0].priority(), QueuePriority::strict(10));

Re-exports§

pub use catalog::CommandClass;
pub use catalog::CommandDescriptor;
pub use catalog::OperationSafety;
pub use catalog::PayloadConstraint;
pub use catalog::command_descriptor;
pub use catalog::request_constraint;
pub use inspect::ExchangeReport;
pub use inspect::FrameReport;
pub use inspect::InspectionIssue;
pub use inspect::MAXIMUM_INSPECTION_TEXT_BYTES;
pub use inspect::inspect_base64;
pub use inspect::inspect_bytes;
pub use inspect::inspect_exchange;
pub use inspect::inspect_hex;
pub use operation::CheckedOperation;
pub use operation::CommandCode;
pub use operation::CommandOutcome;
pub use operation::DeviceReply;
pub use operation::Operation;
pub use operation::OperationError;
pub use operation::RawOperation;
pub use operation::Request;
pub use wire::Address;
pub use wire::ChecksumPolicy;
pub use wire::DecodeEvent;
pub use wire::DecodeLimits;
pub use wire::DecodeLimitsError;
pub use wire::Frame;
pub use wire::FrameDecoder;
pub use wire::FrameKind;
pub use wire::FrameRepair;
pub use wire::MAX_ENCODED_FRAME_SIZE;
pub use wire::MAXIMUM_DECODE_BUFFER_CAPACITY;
pub use wire::MAXIMUM_DECODE_EVENTS_PER_PUSH;
pub use wire::Master;
pub use wire::PhysicalLayer;
pub use wire::WireError;
pub use service::AdaptiveTiming;
pub use service::CommandContext;
pub use service::CommandPolicy;
pub use service::CommandRouting;
pub use service::DEFAULT_LATE_RESPONSE_GUARD;
pub use service::DeviceHealthConfigError;
pub use service::DeviceHealthOptions;
pub use service::DeviceHealthSnapshot;
pub use service::DeviceSnapshot;
pub use service::ExchangeError;
pub use service::LinkBuildError;
pub use service::LinkBuilder;
pub use service::LinkClient;
pub use service::LinkConfig;
pub use service::LinkConfigError;
pub use service::LinkEvent;
pub use service::LinkRunner;
pub use service::LinkSnapshot;
pub use service::MAXIMUM_LATE_RESPONSE_GUARD;
pub use service::MAXIMUM_QUEUE_CAPACITY;
pub use service::MAXIMUM_RETRY_DURATION;
pub use service::MAXIMUM_TOTAL_QUEUE_CAPACITY;
pub use service::MAXIMUM_TRANSMIT_PREFIX;
pub use service::ManagedDeviceSession;
pub use service::ManagedSessionError;
pub use service::PendingReply;
pub use service::QueueClient;
pub use service::QueueConfig;
pub use service::QueueConfigError;
pub use service::QueueError;
pub use service::QueueId;
pub use service::QueuePriority;
pub use service::QueueSnapshot;
pub use service::RetryCause;
pub use service::RetryPolicy;
pub use service::RetryPolicyError;
pub use service::SnapshotError;
pub use service::SnapshotField;
pub use service::SnapshotOptions;
pub use service::StartError;

Modules§

catalog
Registry of known operations and their declared properties. Explicit registry of known commands without broad range classification.
channel
I/O channels for physical and network links. Asynchronous byte channels with no HART-specific logic.
inspect
Validation and explanation of complete frames. Fast structural frame inspection for development and link diagnostics.
operation
Typed operations grouped by purpose. Application-level requests and responses.
profile
Physical-link, gateway, and device-discovery profiles. Validated settings for a physical link and transparent gateway.
service
Exchange queue, runner, and device session. Command execution through independently bounded, application-defined queues.
tables
Versioned common tables that preserve unknown codes. Versioned resolution of codes from HART common tables.
telemetry
Metric snapshots independent of a specific observability system. Export of bounded metrics to an external observability system.
trace
Recording and replay of byte-exact exchanges. Byte-exact channel recording and deterministic scenario replay.
verification
Local functional campaigns against an emulator or hardware. Repeatable functional campaigns without claims of official certification.
wire
Link-layer byte representation and streaming decoding. Canonical HART frame representation and streaming decoder.