moto-hses-client

Crates.iomoto-hses-client
lib.rsmoto-hses-client
version0.2.1
created_at2025-09-21 23:15:58.889729+00
updated_at2026-01-25 01:16:10.822504+00
descriptionAsync UDP client for Yaskawa High-Speed Ethernet Server (HSES) communication
homepagehttps://github.com/masayuki-kono/moto-hses
repositoryhttps://github.com/masayuki-kono/moto-hses
max_upload_size
id1849299
size292,997
masayuki-kono (masayuki-kono)

documentation

https://docs.rs/moto-hses-client

README

moto-hses-client

Crates.io Documentation License Gate of Main Security Audit CodeRabbit Pull Request Reviews

Async UDP client for Yaskawa High-Speed Ethernet Server (HSES) communication.

Overview

This crate provides a high-level, type-safe, asynchronous Rust client for communicating with Yaskawa robots using the HSES (High Speed Ethernet Server) protocol over UDP. It's built on top of Tokio and provides a modern async/await API.

Verified Robot Models

The following robot models have been tested and verified for compatibility:

Robot Model Status
DX100 ❌ Not verified
FS100 ❌ Not verified
DX200 ❌ Not verified
YRC1000 ❌ Not verified
YRC1000micro ✅ Verified

Supported Commands

Robot Control Commands

Command No Command Name
0x70 Alarm Data Reading Command
0x71 Alarm History Reading Command
0x72 Read Status Information
0x73 Executing Job Information Reading Command
0x75 Robot Position Data Reading Command
0x78 I/O Data Reading / Writing Command
0x79 Register Data Reading / Writing Command
0x7A Byte Variable (B) Reading / Writing Command
0x7B Integer Type Variable (I) Reading / Writing Command
0x7C Double Precision Integer Type Variable (D) Reading / Writing Command
0x7D Real Type Variable (R) Reading / Writing Command
0x7E Character Type Variable (S) Reading / Writing Command
0x82 Alarm Reset / Error Cancel Command
0x83 Hold / Servo On/off Command
0x84 Step / Cycle / Continuous Switching Command
0x86 Start-up (Job Start) Command
0x87 Job Select Command
0x300 Plural I/O Data Reading / Writing Command
0x301 Plural Register Data Reading / Writing Command
0x302 Plural Byte Type Variable (B) Reading / Writing Command
0x303 Plural Integer Type Variable (I) Reading / Writing Command
0x304 Plural Double Precision Integer Type Variable (D) Reading / Writing Command
0x305 Plural Real Type Variable (R) Reading / Writing Command
0x306 Plural Character Type Variable (S) Reading / Writing Command

File Control Commands

Service Command Name
0x09 File Delete
0x16 File saving command (Controller to the PC)
0x32 File list acquiring

Features

  • Async/await support: Built on Tokio for high-performance async I/O
  • Type-safe API: Leverages Rust's type system for compile-time safety
  • Comprehensive operations: Support for all HSES protocol operations

Installation

Add this to your Cargo.toml:

[dependencies]
moto-hses-client = "0.2"
tokio = { version = "1.0", features = ["full"] }

Usage

use moto_hses_client::HsesClient;
use moto_hses_proto::AlarmAttribute;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create client
    let client = HsesClient::new("192.168.0.3:10040").await?;

    // Read alarm data
    let alarm = client.read_alarm_data(1, AlarmAttribute::All).await?;
    println!("Alarm Code: {}", alarm.code);
    println!("Alarm Name: {}", alarm.name);

    // Reset alarm
    client.reset_alarm().await?;
    println!("Alarm reset completed");

    Ok(())
}

Examples

The crate includes comprehensive examples in the examples/ directory:

  • alarm_operations.rs - Alarm data handling
  • byte_variable_operations.rs - Byte variable (B) read/write operations
  • cycle_mode_control.rs - Cycle mode switching operations
  • double_variable_operations.rs - Double variable (D) read/write operations
  • file_operations.rs - File transfer operations
  • hold_servo_control.rs - Servo control operations
  • integer_variable_operations.rs - Integer variable (I) read/write operations
  • io_operations.rs - I/O operations
  • job_select.rs - Job selection operations
  • job_start.rs - Job start operations
  • position_operations.rs - Position data operations
  • read_executing_job_info.rs - Job information
  • read_status.rs - Status monitoring
  • real_variable_operations.rs - Real variable (R) read/write operations
  • register_operations.rs - Register operations
  • string_variable_operations.rs - String variable (S) read/write operations

Running Examples

# Run a specific example
RUST_LOG=info cargo run --example alarm_operations -- 192.168.0.3 10040

Testing

The crate can be tested using the separate moto-hses-mock crate:

[dev-dependencies]
moto-hses-mock = "0.2"
use moto_hses_client::HsesClient;
use moto_hses_mock::{MockServer, MockServerBuilder};
use moto_hses_proto::Alarm;

#[tokio::test]
async fn test_alarm_operations() {
    // Start mock server with test alarm
    let server = MockServerBuilder::new()
        .host("127.0.0.1")
        .robot_port(10040)
        .file_port(10041)
        .with_alarm(Alarm::new(1001, 0, 0, "2024-01-01 12:00:00".to_string(), "Test alarm".to_string()))
        .build()
        .await
        .unwrap();
    
    // Start the server in the background
    let server_handle = tokio::spawn(async move {
        server.run().await.unwrap();
    });
    
    let client = HsesClient::new("127.0.0.1:10040").await.unwrap();
    
    // Test alarm operations
    let alarm = client.read_alarm_data(1, AlarmAttribute::All).await.unwrap();
    assert_eq!(alarm.code, 1001);
    assert_eq!(alarm.name, "Test alarm");
    
    // Test alarm reset
    client.reset_alarm().await.unwrap();
    
    // Clean up
    server_handle.abort();
}

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Related Crates

References

Commit count: 366

cargo fmt