Skip to main content

Crate plc_comm_slmp

Crate plc_comm_slmp 

Source
Expand description

Async Rust client for Mitsubishi SLMP Binary 3E and 4E.

This crate follows the same operation semantics as the sibling plc-comm-slmp-python, .NET, C++, Node-RED, and cross-verify projects in the same family. The intended flow is:

  1. connect with SlmpConnectionOptions and SlmpClient
  2. use raw device APIs for low-level control
  3. use helper APIs such as read_named and write_named for application-facing snapshots and typed values
  4. validate behavior through plc-comm-slmp-cross-verify

§Quick Start

use plc_comm_slmp::{
    SlmpAddress, SlmpClient, SlmpCompatibilityMode, SlmpConnectionOptions, SlmpFrameType,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut options = SlmpConnectionOptions::new("192.168.250.100");
    options.port = 1025;
    options.frame_type = SlmpFrameType::Frame4E;
    options.compatibility_mode = SlmpCompatibilityMode::Iqr;

    let client = SlmpClient::connect(options).await?;
    let words = client.read_words_raw(SlmpAddress::parse("D100")?, 2).await?;
    println!("{words:?}");
    Ok(())
}
use plc_comm_slmp::{
    NamedAddress, SlmpClient, SlmpCompatibilityMode, SlmpConnectionOptions, SlmpFrameType,
    SlmpValue, read_named, write_named,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut options = SlmpConnectionOptions::new("192.168.250.100");
    options.port = 1025;
    options.frame_type = SlmpFrameType::Frame4E;
    options.compatibility_mode = SlmpCompatibilityMode::Iqr;
    let client = SlmpClient::connect(options).await?;

    let snapshot = read_named(
        &client,
        &["D100".into(), "D200:F".into(), "D50.3".into(), "LTN10:D".into()],
    )
    .await?;
    println!("{snapshot:?}");

    let mut updates = NamedAddress::new();
    updates.insert("D300".into(), SlmpValue::U16(42));
    updates.insert("D400:F".into(), SlmpValue::F32(3.14));
    write_named(&client, &updates).await?;
    Ok(())
}

§Address Notes

  • Plain word devices: D100, R50, ZR0
  • Plain bit devices: M100, X20, Y20, B10
  • Typed suffixes: D200:F, D300:D, D400:L
  • Bit-in-word form: D50.3
  • Long current values: LTN10:D, LSTN20:D, LCN30:D
  • Extended devices: J1\\W10, U3\\G100, U1\\HG0

.bit notation is only valid for word devices. Long timer and long counter state reads (LTS, LTC, LSTS, LSTC, LCS, LCC) are normalized through the corresponding current-value block reads.

§Examples

The repository includes runnable examples under examples/:

  • raw_read_write
  • named_helpers
  • advanced_operations

Run them with cargo run --example <name>.

§Verification

This crate is meant to participate in plc-comm-slmp-cross-verify. The canonical wrapper binary is slmp_verify_client.

Structs§

SlmpAddress
SlmpBlockRead
SlmpBlockReadResult
SlmpBlockWrite
SlmpBlockWriteOptions
SlmpClient
SlmpConnectionOptions
SlmpDeviceAddress
SlmpError
SlmpExtensionSpec
SlmpLongTimerResult
SlmpNamedTarget
SlmpQualifiedDeviceAddress
SlmpRandomReadResult
SlmpTargetAddress
SlmpTypeNameInfo

Enums§

SlmpCommand
SlmpCompatibilityMode
SlmpDeviceCode
SlmpFrameType
SlmpTraceDirection
SlmpTransportMode
SlmpValue

Functions§

encode_device_spec
normalize_named_address
parse_named_address
parse_named_target
parse_qualified_device
parse_scalar_for_named
parse_target_auto_number
poll_named
read_dwords_chunked
read_dwords_single_request
read_named
read_typed
read_words_chunked
read_words_single_request
write_bit_in_word
write_dwords_chunked
write_dwords_single_request
write_named
write_typed
write_words_chunked
write_words_single_request

Type Aliases§

NamedAddress