Skip to content

Commit e1aa1e7

Browse files
committed
fix type setter for pdos
1 parent a61d500 commit e1aa1e7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.4.12
2+
3+
* update object dictionary on type change in PDOs
4+
15
# 0.4.11
26

37
* check limits for numeric datatypes when using `object_dictionary.write`

src/durand/services/pdo/rpdo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, node: "Node", index: int):
5454
def _set_transmission_type(self, value: int):
5555
self._deactivate_mapping()
5656
self._transmission_type = value
57+
self._node.object_dictionary.write(0x1400 + self._index, 2, value)
5758
self._activate_mapping()
5859

5960
def _update_od_cob_id(self):

src/durand/services/pdo/tpdo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def _set_transmission_type(self, value: int):
130130

131131
self._transmission_type = value
132132

133+
self._node.object_dictionary.write(0x1800 + self._index, 2, value)
134+
133135
def _update_inhibit_time(self, value: int):
134136
if self._inhibit_timer:
135137
self._inhibit_timer.cancel()
@@ -147,7 +149,7 @@ def inhibit_time(self):
147149

148150
@inhibit_time.setter
149151
def inhibit_time(self, value: float):
150-
return self._node.object_dictionary.write(
152+
self._node.object_dictionary.write(
151153
0x1800 + self._index, 3, value * 10_000
152154
)
153155

tests/example_based/test_rpdo_sync.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ def test_rpdo_sync():
1515
# add a variable with index 0x2000 to the object dictionary of the node
1616
node.object_dictionary[0x2000] = Variable(DT.INTEGER16, "rw", value=5)
1717

18+
node.rpdo[0].transmission_type = 0 # set transmission type to sync
19+
1820
# receive PDO message after changing into Operational state
1921
network.test(
2022
[ TxMsg(0x702, "00"), # boot-up message from NMT
2123

22-
RxMsg(0x602, "2F 00 14 02 00 00 00 00"), # set transmission type to 0
23-
TxMsg(0x582, "60 00 14 02 00 00 00 00"), # response (acknowledge)
24-
2524
RxMsg(0x602, "23 00 16 01 02 00 00 20"), # set mapping of 0x2000:0
2625
TxMsg(0x582, "60 00 16 01 00 00 00 00"), # response (acknowledge)
2726

@@ -31,7 +30,10 @@ def test_rpdo_sync():
3130
RxMsg(0x000, "80 00"), # set NMT Pre-Operational state
3231
RxMsg(0x000, "01 00"), # set NMT Operational state
3332

34-
RxMsg(0x202, "02 00") # receive the PDO message (will be ignored until sync)
33+
RxMsg(0x202, "02 00"), # receive the PDO message (will be ignored until sync)
34+
35+
RxMsg(0x602, "40 00 14 02 00 00 00 00"), # get transmission type
36+
TxMsg(0x582, "4F 00 14 02 00 00 00 00"), # receive type 0
3537
]
3638
)
3739

0 commit comments

Comments
 (0)