Crate etherage

Source
Expand description

Etherage is a crate implementing an ethercat master, with an API as close as possible to the concepts of the ethercat protocol.

The following scheme shows the ethernet topology of an ethercat bus. It is a ring considering directional arrows (which is the way data transits over the bus). And it is a tree considering bilateral links (which is the way the network is wired).

ethercat network topology

Each slave only has a very short time and very limited ressources to react & alter the datagrams transiting from one of its port to the next one, resulting in a realtime communcation bus. This library and the ethercat protocol are designed in this spirit. The idea is for the master to send datagrams and for the slaves to react and fill them, few bytes each slave. In order to control a vast amount of slaves concurrently in the same datagram, this library is deeply async.

§It mainly features

  • Master for protocol-safe and memory-safe access to the functions of the master
  • Slave for protocol-safe and memory-safe access to the functions of slaves
  • RawMaster and other structures based on it for memory-safe but protocol-unsafe access to lower level features of the protocol

§Complete feature list

  • master over different sockets
    • raw ethernet
    • UDP
  • minimalistic features
    • PDU commands
    • access to logical & physical memories
    • slave information access
  • mailbox
    • generic messaging
    • COE
      • SDO read/write
      • PDO read/write
      • informations
      • tools for mapping
    • EOE
    • FOE
  • distributed clock
    • static drift
    • dynamic drift
  • convenience
    • logical memory & slave group management tools
    • mapping tools
  • optimization features
    • multiple PDUs per ethercat frame (speed up and compress transmissions)
    • tasks for different slaves or for same slave are parallelized whenever possible
    • no dynamic allocation in transmission and realtime functions
    • async API and implementation to avoid threads context switches

Re-exports§

pub use crate::data::PduData;
pub use crate::data::Field;
pub use crate::data::BitField;
pub use crate::sdo::Sdo;
pub use crate::rawmaster::RawMaster;
pub use crate::rawmaster::SlaveAddress;
pub use crate::master::Master;
pub use crate::slave::Slave;
pub use crate::slave::CommunicationState;
pub use crate::mapping::Mapping;
pub use crate::mapping::Group;
pub use crate::mapping::Config;
pub use crate::error::EthercatError;
pub use crate::error::EthercatResult;
pub use crate::socket::*;

Modules§

can
implementation of CoE (Canopen Over Ethercat)
clock
Implementation of clock synchonization between master and slaves.
data
Traits and impls used to read/write data to/from the wire.
eeprom
This module expose the standard slaves EEPROM registers.
error
definition of the general ethercat error type
mailbox
implementation of communication with a slave’s mailbox
mapping
This module provide helper structs to configure and use the memory mappings of an arbitrary bunch of slaves.
master
rawmaster
low level ethercat communication functions.
registers
structs and consts for every registers in a standard slave’s RAM. This should be used instead of any hardcoded register value.
sdo
Convenient structures to address the slave’s dictionnary objects (SDO).
sii
SII (Slave Information Interface) allows to retreive from EEPROM declarative informations about a slave (like a manifest) like product code, vendor, etc as well as slave boot-up configs.
slave
socket
This module provide the trait EthercatSocket, and several implementors allowing to use different physical layers for ethercat communication.

Macros§

array_pdudata
unsafe macro implementing PduData for arrays of a given struct with repr(packed)
bilge_pdudata
macro implementing PduData for a given struct generated with bilge this is an ugly unsafe code to overcome the lack of traits providing containing ints in bilge
packed_pdudata
unsafe macro implementing PduData for a given struct with repr(packed)