Skip to content

Commit 67fbd02

Browse files
committed
Fix mixed up mapping parameter record index numbers in class PDO.
The access by this index number mixed up the two number ranges. The CiA 301 standard defines: * Object 1600h to 17FFh: RPDO mapping parameter * Object 1A00h to 1BFFh: TPDO mapping parameter The test was also wrong, because it added the two tested variables to the TPDO1, while testing the __getitem__ lookup with index 0x1600.
1 parent 2c4450e commit 67fbd02

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

canopen/pdo/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def __init__(self, node, rpdo, tpdo):
3232
self.map = {}
3333
# the object 0x1A00 equals to key '1' so we remove 1 from the key
3434
for key, value in self.rx.items():
35-
self.map[0x1A00 + (key - 1)] = value
36-
for key, value in self.tx.items():
3735
self.map[0x1600 + (key - 1)] = value
36+
for key, value in self.tx.items():
37+
self.map[0x1A00 + (key - 1)] = value
3838

3939

4040
class RPDO(PdoBase):

test/test_pdo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_pdo_getitem(self):
5050
self.assertEqual(node.tpdo[1]['BOOLEAN value 2'].raw, True)
5151

5252
# Test different types of access
53-
by_mapping_record = node.pdo[0x1600]
53+
by_mapping_record = node.pdo[0x1A00]
5454
self.assertIsInstance(by_mapping_record, canopen.pdo.PdoMap)
5555
self.assertEqual(by_mapping_record['INTEGER16 value'].raw, -3)
5656
by_object_name = node.pdo['INTEGER16 value']
@@ -68,7 +68,7 @@ def test_pdo_getitem(self):
6868
self.assertEqual(by_object_index.raw, 0xf)
6969
self.assertIs(node.pdo['0x2002'], by_object_index)
7070
self.assertIs(node.tpdo[0x2002], by_object_index)
71-
self.assertIs(node.pdo[0x1600][0x2002], by_object_index)
71+
self.assertIs(node.pdo[0x1A00][0x2002], by_object_index)
7272

7373
self.assertRaises(KeyError, lambda: node.pdo[0])
7474
self.assertRaises(KeyError, lambda: node.tpdo[0])

0 commit comments

Comments
 (0)