Closed jamwaffles closed 9 months ago
Caution!! This has been tested with the revision 73440a66eca1509e6c8dd8da1aa7b4966aebc6e1
ethercrab = { git = "https://github.com/ethercrab-rs/ethercrab.git", rev = "73440a66eca1509e6c8dd8da1aa7b4966aebc6e1", features = [
"serde",
] }
Testing reading and writing bool data:
let avg_mode_original = slave.sdo_read::<bool>(0x8000, 4).await?;
slave.sdo_write(0x8000, 4, false).await?;
let avg_mode_new = slave.sdo_read::<bool>(0x8000, 4).await?;
log::info!(
"Avg Mode. Original {:?}, Updated {:?}",
avg_mode_original,
avg_mode_new
);
Testing f32
let nominal_original = slave.sdo_read::<f32>(0x8000, 0x23).await?;
slave.sdo_write(0x8000, 0x23, 4.0f32).await?;
let nominal_new = slave.sdo_read::<f32>(0x8000, 0x23).await?;
log::info!(
"Nominal. Original {:?}, Updated {:?}",
nominal_original,
nominal_new
);
Output:
[2024-02-13T23:27:05Z INFO testing::ethercat_master] Nominal. Original 2.0, Updated 4.0
Warning: This test belongs to the revision {25596d55801b295d6a0afc20cd73532415e8fd0e} where bool is translated as false 0x00 true 0xff
ethercrab = { git = "https://github.com/ethercrab-rs/ethercrab.git", rev = "25596d55801b295d6a0afc20cd73532415e8fd0e", features = [
"serde",
] }
Testing code:
let avg_mode_original = slave.sdo_read::<bool>(0x8000, 4).await?;
slave.sdo_write(0x8000, 4, false).await?;
let avg_mode_new = slave.sdo_read::<bool>(0x8000, 4).await?;
log::info!(
"Avg Mode. Original {:?}, Updated {:?}",
avg_mode_original,
avg_mode_new
);
Output:
[2024-02-13T23:33:30Z INFO testing::ethercat_master] Avg Mode. Original true, Updated false
Note that
f64
s cannot currently be passed tosdo_write
as it only supports 4 byte expedited transfers currently.