Open
Conversation
Member
|
@khalilbendhief please explain why you needed to change the Bus Coupler code and whats different now. Please also fix the rust formating error. @kraemr please take a look. |
kraemr
requested changes
Apr 8, 2026
Collaborator
kraemr
left a comment
There was a problem hiding this comment.
Fix Formatting Error, and Electron errors and remove your coupler logic changes for the Wago 750-354 unless they are absolutely necessary
Comment on lines
112
to
210
| fn set_module(&mut self, module: Module) { | ||
| self.slots[self.module_count] = Some(module.clone()); | ||
| self.module_count += 1; | ||
| } | ||
| } | ||
|
|
||
| impl EthercatDeviceUsed for Wago750_354 { | ||
| fn is_used(&self) -> bool { | ||
| self.is_used | ||
| } | ||
|
|
||
| fn set_used(&mut self, used: bool) { | ||
| self.is_used = used; | ||
| } | ||
| } | ||
|
|
||
| impl EthercatDeviceProcessing for Wago750_354 {} | ||
|
|
||
| impl NewEthercatDevice for Wago750_354 { | ||
| fn new() -> Self { | ||
| Self { | ||
| is_used: false, | ||
| slots: [const { None }; 64], | ||
| slot_devices: [const { None }; 64], | ||
| module_count: 0, | ||
| dev_count: 0, | ||
| tx_size: 0, | ||
| rx_size: 0, | ||
| rx_pdo_mappings: vec![], | ||
| tx_pdo_mappings: vec![], | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl std::fmt::Debug for Wago750_354 { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| write!(f, "Wago_750_354") | ||
| } | ||
| } | ||
|
|
||
| impl Wago750_354 { | ||
| pub fn calculate_module_index(pdo_mapping: u32, is_tx: bool) -> u32 { | ||
| let start_index = match is_tx { | ||
| true => 0x6000, | ||
| false => 0x7000, | ||
| }; | ||
| let pdo_index = (pdo_mapping & 0xFFFF0000) >> 16; | ||
|
|
||
| if pdo_index < start_index { | ||
| // Treat as coupler/module 0 | ||
| return 0; | ||
| } | ||
|
|
||
| let index_in_hex = pdo_index - start_index; | ||
|
|
||
| if index_in_hex < 16 { | ||
| 0 | ||
| } else { | ||
| index_in_hex / 16 | ||
| } | ||
| } | ||
|
|
||
| pub async fn get_pdo_offsets<'a>( | ||
| &mut self, | ||
| device: &EthercrabSubDevicePreoperational<'a>, | ||
| get_tx: bool, | ||
| ) -> Result<(), Error> { | ||
| let mut vec: Vec<ModulePdoMapping> = vec![]; | ||
| let mut bit_offset = 0; | ||
| let start_subindex = 0x2; | ||
|
|
||
| let index = match get_tx { | ||
| true => (TX_MAPPING_INDEX.0, TX_MAPPING_INDEX.1), | ||
| false => (RX_MAPPING_INDEX.0, RX_MAPPING_INDEX.1), | ||
| }; | ||
|
|
||
| let count_mappings = device.sdo_read::<u8>(index.0, index.1).await?; | ||
| let pdo_index = device.sdo_read::<u16>(index.0, 1).await?; | ||
| let pdo_map_count = device.sdo_read::<u8>(pdo_index, 0).await?; | ||
|
|
||
| for i in 0..pdo_map_count { | ||
| let pdo_mapping: u32 = device.sdo_read(pdo_index, 1 + i).await?; | ||
| let bit_length = (pdo_mapping & 0xFF) as u8; | ||
| bit_offset += bit_length as usize; | ||
| } | ||
|
|
||
| for i in start_subindex..=count_mappings { | ||
| let pdo_index = device.sdo_read(index.0, i).await?; | ||
| let pdo_map_count = device.sdo_read::<u8>(pdo_index, 0).await?; | ||
| for j in 0..pdo_map_count { | ||
| let pdo_mapping: u32 = device.sdo_read(pdo_index, 1 + j).await?; | ||
| let pdo_index_hi = (pdo_mapping & 0xFFFF0000) >> 16; | ||
| let bit_length = (pdo_mapping & 0xFF) as usize; | ||
|
|
||
| // Preserve the original coupler assignment order. Padding/alignment | ||
| // entries still consume bits, but must not be assigned to a module. | ||
| let start_index = if get_tx { 0x6000 } else { 0x7000 }; | ||
| if pdo_index_hi >= start_index { | ||
| let module_i = Wago750_354::calculate_module_index(pdo_mapping, get_tx); |
Collaborator
There was a problem hiding this comment.
Why did you change the logic in here ?
Collaborator
There was a problem hiding this comment.
@khalilbendhief maybe just cherry-pick your new machine integration on top of current master since the coupler code is functional now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the
wago_dio_separatemachine, combining a WAGO 750-430(8-channel DI) and 750-530 (8-channel DO) under a single EtherCAT
machine abstraction.