#hardware #scada #secop #sample-environment

macro secop-derive

A Rust framework for a hardware server speaking the SECoP protocol (derive package)

1 unstable release

0.1.3 Jun 20, 2022

#39 in #scada

24 downloads per month
Used in 3 crates (2 directly)

GPL-2.0+

38KB
544 lines

secop-rs

A Rust framework and demo devices for a hardware server speaking the SECoP protocol.

Build/run

Install the Rust toolchain, currently the nightly channel is required.

Debug mode (faster compilation): cargo run -- test.cfg.

Release mode (optimized for speed): cargo run --release -- test.cfg.

Organization

The code is (currently) split into four crates:

  • secop-core provides the meat of the framework, and server implementation
  • secop-derive (which has to be separate as a proc-macro crate) helps the framework by auto-generating interface boilerplate
  • secop-modules contains concrete modules
  • secop just has the main executable(s)

lib.rs:

Derive support for secop modules

There are two auto-derive traits implemented here:

  • ModuleBase is a complete implementation of the guts of a module. It provides an easy DSL to add parameters and commands, and translates that into the respective case handling in the methods that implement the basic SECoP actions like change and do.

    It also provides automatic translation and verification between JSON payloads and Rust data for parameter and argument types.

  • TypeDesc can be derived for enums and structs, and provides a type- safe way to declare parameters and commands with enum and struct datatypes.

Dependencies

~2MB
~47K SLoC