@@ -57,28 +57,24 @@ def associate_network(self, network: Network):
57
57
self .tpdo .network = network
58
58
self .rpdo .network = network
59
59
self .nmt .network = network
60
+ for sdo in self .sdo_channels :
61
+ network .subscribe (sdo .tx_cobid , sdo .on_response )
60
62
if network .is_async ():
61
- for sdo in self .sdo_channels :
62
- network .subscribe (sdo .tx_cobid , sdo .aon_response )
63
63
network .subscribe (0x700 + self .id , self .nmt .aon_heartbeat )
64
64
network .subscribe (0x80 + self .id , self .emcy .aon_emcy )
65
65
else :
66
- for sdo in self .sdo_channels :
67
- network .subscribe (sdo .tx_cobid , sdo .on_response )
68
66
network .subscribe (0x700 + self .id , self .nmt .on_heartbeat )
69
67
network .subscribe (0x80 + self .id , self .emcy .on_emcy )
70
68
network .subscribe (0 , self .nmt .on_command )
71
69
72
70
def remove_network (self ):
73
71
network = self .network
72
+ for sdo in self .sdo_channels :
73
+ network .unsubscribe (sdo .tx_cobid , sdo .on_response )
74
74
if network .is_async ():
75
- for sdo in self .sdo_channels :
76
- network .unsubscribe (sdo .tx_cobid , sdo .aon_response )
77
75
network .unsubscribe (0x700 + self .id , self .nmt .aon_heartbeat )
78
76
network .unsubscribe (0x80 + self .id , self .emcy .aon_emcy )
79
77
else :
80
- for sdo in self .sdo_channels :
81
- network .unsubscribe (sdo .tx_cobid , sdo .on_response )
82
78
network .unsubscribe (0x700 + self .id , self .nmt .on_heartbeat )
83
79
network .unsubscribe (0x80 + self .id , self .emcy .on_emcy )
84
80
network .unsubscribe (0 , self .nmt .on_command )
@@ -105,10 +101,7 @@ def add_sdo(self, rx_cobid, tx_cobid):
105
101
client = SdoClient (rx_cobid , tx_cobid , self .object_dictionary )
106
102
self .sdo_channels .append (client )
107
103
if self .network is not None :
108
- if self .network .is_async ():
109
- self .network .subscribe (client .tx_cobid , client .aon_response )
110
- else :
111
- self .network .subscribe (client .tx_cobid , client .on_response )
104
+ self .network .subscribe (client .tx_cobid , client .on_response )
112
105
return client
113
106
114
107
def store (self , subindex = 1 ):
0 commit comments