From fa554eeb78cd07fe336d8de5694cda40dce1b0f9 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 24 Aug 2024 13:34:05 +0200 Subject: [PATCH] bump to ethercat-esi 0.2 for cyclic-data info example fixes #47 --- Cargo.toml | 2 +- examples/cyclic-data.rs | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7395936..e26c616 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ num-traits = "0.2" thiserror = "1.0" [dev-dependencies] -ethercat-esi = "0.1" +ethercat-esi = "0.2" env_logger = "0.8" [features] diff --git a/examples/cyclic-data.rs b/examples/cyclic-data.rs index 065eb5e..9cb550f 100644 --- a/examples/cyclic-data.rs +++ b/examples/cyclic-data.rs @@ -1,7 +1,6 @@ use ethercat::{ - AlState, DomainIdx as DomainIndex, Idx, Master, MasterAccess, Offset, PdoCfg, PdoEntryIdx, - PdoEntryIdx as PdoEntryIndex, PdoEntryInfo, PdoEntryPos, PdoIdx, SlaveAddr, SlaveId, SlavePos, - SmCfg, SubIdx, + AlState, DomainIdx as DomainIndex, Master, MasterAccess, Offset, PdoCfg, PdoEntryIdx, + PdoEntryInfo, PdoEntryPos, SlaveAddr, SlaveId, SlavePos, SmCfg, }; use ethercat_esi::EtherCatInfo; use std::{ @@ -64,7 +63,7 @@ pub fn main() -> Result<(), io::Error> { } } -type SlaveMap = HashMap>; +type SlaveMap = HashMap>; pub fn init_master( esi: &EtherCatInfo, @@ -75,7 +74,7 @@ pub fn init_master( master.reserve()?; log::debug!("Create domain"); let domain_idx = master.create_domain()?; - let mut offsets: HashMap> = HashMap::new(); + let mut offsets: HashMap> = HashMap::new(); for (dev_nr, dev) in esi.description.devices.iter().enumerate() { let slave_pos = SlavePos::from(dev_nr as u16); @@ -89,22 +88,19 @@ pub fn init_master( product_code: dev.product_code, }; let mut config = master.configure_slave(slave_addr, slave_id)?; - let mut entry_offsets: HashMap = HashMap::new(); + let mut entry_offsets: HashMap = HashMap::new(); let rx_pdos: Vec = dev .rx_pdo .iter() .map(|pdo| PdoCfg { - idx: PdoIdx::from(pdo.index), + idx: pdo.idx, entries: pdo .entries .iter() .enumerate() .map(|(i, e)| PdoEntryInfo { - entry_idx: PdoEntryIdx { - idx: Idx::from(e.index), - sub_idx: SubIdx::from(e.sub_index.unwrap_or(1) as u8), - }, + entry_idx: e.entry_idx, bit_len: e.bit_len as u8, name: e.name.clone().unwrap_or_default(), pos: PdoEntryPos::from(i as u8), @@ -117,16 +113,13 @@ pub fn init_master( .tx_pdo .iter() .map(|pdo| PdoCfg { - idx: PdoIdx::from(pdo.index), + idx: pdo.idx, entries: pdo .entries .iter() .enumerate() .map(|(i, e)| PdoEntryInfo { - entry_idx: PdoEntryIdx { - idx: Idx::from(e.index), - sub_idx: SubIdx::from(e.sub_index.unwrap_or(1) as u8), - }, + entry_idx: e.entry_idx, bit_len: e.bit_len as u8, name: e.name.clone().unwrap_or_default(), pos: PdoEntryPos::from(i as u8),