You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let slave = slaves.get(&address).unwrap().as_ref();
468
+
})));
469
+
// uncontroled reference to self and to configuration
470
+
// this is safe since the slave config will not be removed from the hashmap and cannot be moved since it is heap allocated
471
+
// the returned instance holds an immutable reference to self so it cannot be freed
472
+
let slave = unsafe{core::mem::transmute::<_,&Box<RwLock<_>>>(
473
+
slaves.get(&address).unwrap()
474
+
)};
476
475
MappingSlave{
477
-
// uncontroled reference to self and to configuration
478
-
// this is safe since the config parts that will be accessed by this new slave shall be accessed only by it
479
-
// the returned instance holds an immutable reference to self so it cannot be freed
480
-
config:unsafe{&mut*(slave as*const_as*mut_)},
476
+
config: slave.try_write().expect("slave already in mapping"),
481
477
mapping:self,
482
478
buffer:SLAVE_PHYSICAL_MAPPABLE.start,
483
479
additional:0,
@@ -493,7 +489,7 @@ impl<'a> Mapping<'a> {
493
489
/// data coming from one's slave physical memory shall not interlace (this is a limitation due to this library, not ethercat) so any mapping methods in here are preventing multiple mapping instances
494
490
pubstructMappingSlave<'a>{
495
491
mapping:&'aMapping<'a>,
496
-
config:&'amutConfigSlave,
492
+
config:RwLockWriteGuard<'a,ConfigSlave>,
497
493
/// position in the physical memory mapping region
498
494
buffer:u16,
499
495
/// increment to add to `buffer` once the current mapped channel is done.
0 commit comments