Closed flosse closed 4 years ago
Looks like we should definitely support this. However, there seems to be two differences here:
REQUEST
ioctl on the masterAccording to the header docs, this is necessary for registering domains/PDOs and realtime access.
MasterDevice::Read
or MasterDevice::ReadWrite
(in the C++ terminology in tool/
)Commands like upload
only need read access, while e.g. download
needs read-write. REQUEST also needs read-write.
So IMO either we do enum AccessType { ReadOnly, ReadWrite, Realtime }
or we separate the open(Permission)
and request()
operations like you did in the PR.
Regarding master_count
, it should probably be a static method that opens its own FD, just to query this, like in the C++ code (see tool/Command.cpp
, line 50.)
So IMO either we do
enum AccessType { ReadOnly, ReadWrite, Realtime }
or we separate theopen(Permission)
andrequest()
operations like you did in the PR.
One the one side I like the idea of a simple API with a single open
method but probably there are scenarios where you might need a better control?
Currently my favorite solution is
open(index, permission)
method with either MasterAccess::ReadOnly
or MasterAccess::ReadWrite
reserve()
method (like in lib/master.c
line 45) to get realtime functionalities.Regarding
master_count
, it should probably be a static method that opens its own FD, just to query this, like in the C++ code (seetool/Command.cpp
, line 50.)
:+1:
Motivation
I tried to periodically receive PDOs and execute the
Master::sdo_upload
method once in a while but that leads to a totally blocked process (zombie process). I have no idea why.Then I tried to do the cycles with my Rust application and manually read/write SDOs via the CLI (e.g.
/opt/etherlab/bin/ethercat download -t float 0x8022 1 10.9
) and it worked fine.So I had a look at the CLI code (
CommandUpload.cpp
) where I found this line that creates the access:which executes this code (
tool/MasterDevice.cpp
):This looks similar to the
reserve
method in the rust wrapper:The main difference is this line:
Solution
My solution was to add a
open
method to theMaster
that does not contain the lineioctl!(master, ec::ioctl::REQUEST)?;
and now I'm able to create anotherMaster
instance within an other thread where I can callMaster::sdo_upload
that actually works :)Open Questions
open
method look like?open(idx: MasterIndex, write_access: bool)
open(idx: MasterIndex, access: MasterAccess)
withenum MasterAccess { ReadOnly, ReadWrite }
open_ro(idx: MasterIndex)
open_rw(idx: MasterIndex)
Result<Master>
Result<(Master, usize)>
to get alsomodule_data.master_count
?