-
Notifications
You must be signed in to change notification settings - Fork 202
Network is mixing roles of network access and canopen services #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't see how it hurts to have these services instantiated in any case. A CANopen network simply has these services. Whoever uses them assumes the role of a manager / NMT master / whatever. I don't understand the CANopen is a bit special in this regard because of the promiscuous nature of the bus. Most other protocols have defined messages whose format is fixed, but each instantiation is different because it specifies a sender and possibly a receiver. But in CAN, an object (explicitly not using the term message) simply exists on the bus. Any node can create it, and there is no way to tell which one actually caused the object to appear on the bus. (The extreme case is an RTR frame which can be started by the requesting device, but finished by the responder.) That also allows other nodes to track the state of an SDO server for example, simply by listening to the SDO protocol exchanges. In that regard the SDO server is also something that simply exists on the network, not actually some state explicitly bound to one node. For the client, that is more obvious, since different nodes can query the same SDO server. They need to take care not to step on each other's toes, as it would destroy the SDO server and client internal state (that's why they should listen to the SDO messages even when not sending actively). That's why the spec calls it an "SDO channel" by the way, as the client and server are just roles that any node can assume at a given time. Therefore I find the current object hierarchy in the library mirrors that architecture quite well. Just because an object is instantiated as a member of the |
Regarding terminology, I think the "network interface class" that "provides access to the CAN bus" is actually the |
Its ok. It's fine, but not perfect, to have them there as long as they are never actively transmitting on the bus on their own.
Not all uses of I found this while writing a test case and I noticed that one gets a LSS subscription callback either if you want it or not when |
I don't see that as an error or as being "unstructured". The This may be a matter of taste, but I guess we agree that there is no real need for changing it. Thus let's focus on actual improvements and end this discussion. |
The
class Network
is an abstraction that provides access to the CAN Bus. The current implementation is also assuming additional canopen roles in the same class. The user have no way to avoid that. It instantiatesNmtMaster
,LssMaster
,SyncProducer
,TimeProducer
. All of them are in the current implementation passive, as in, they do not initiate any traffic on their own. This implementation is mixing the role of being a network interface class and providing canopen master functions. As an example, if network is going to be used for passive listening or slave nodes, one would not wantNmtMaster
andLssMaster
.I propose moving the initializations of
SyncProducer
,TimeProducer
,NmtMaster
andLssMaster
to a separate methodNetwork.create_manager()
(manager is the new official name for master in canopen) with a function argument to__init__()
to prevent creation of them. With this the user can opt out of the additional services.Something like this:
canopen/canopen/network.py
Lines 31 to 55 in 48cca7c
The text was updated successfully, but these errors were encountered: