Skip to content

Commit d152e8d

Browse files
committed
Add test for PDO mapping with OD_ARRAY entries
1 parent ad68c17 commit d152e8d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/test_pdo.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ TEST_F (PdoTest, PackWithPadding)
152152
EXPECT_EQ (1u, frame[1]);
153153
}
154154

155+
TEST_F (PdoTest, PackArray)
156+
{
157+
co_pdo_t pdo;
158+
uint8_t * frame = (uint8_t *)&pdo.frame;
159+
const co_obj_t * obj2000 = find_obj (0x2000);
160+
161+
memset (&pdo, 0, sizeof (pdo));
162+
163+
pdo.number_of_mappings = 2;
164+
pdo.mappings[0] = 0x20000308;
165+
pdo.mappings[1] = 0x20000708;
166+
pdo.entries[0] = find_entry (obj2000, 3);
167+
pdo.entries[1] = find_entry (obj2000, 7);
168+
pdo.objs[0] = obj2000;
169+
pdo.objs[1] = obj2000;
170+
171+
co_pdo_pack (&net, &pdo);
172+
EXPECT_EQ (3u, frame[0]);
173+
EXPECT_EQ (7u, frame[1]);
174+
}
175+
155176
TEST_F (PdoTest, Unpack)
156177
{
157178
co_pdo_t pdo;
@@ -236,6 +257,31 @@ TEST_F (PdoTest, UnpackWithPadding)
236257
EXPECT_EQ (0x3322u, value6003_07);
237258
}
238259

260+
TEST_F (PdoTest, UnpackArray)
261+
{
262+
co_pdo_t pdo;
263+
uint8_t * frame = (uint8_t *)&pdo.frame;
264+
const co_obj_t * obj2000 = find_obj (0x2000);
265+
266+
memset (&pdo, 0, sizeof (pdo));
267+
268+
pdo.number_of_mappings = 2;
269+
pdo.mappings[0] = 0x20000308;
270+
pdo.mappings[1] = 0x20000708;
271+
pdo.entries[0] = find_entry (obj2000, 3);
272+
pdo.entries[1] = find_entry (obj2000, 7);
273+
pdo.objs[0] = obj2000;
274+
pdo.objs[1] = obj2000;
275+
276+
frame[0] = 0x00;
277+
frame[1] = 0x11;
278+
279+
co_pdo_unpack (&net, &pdo);
280+
281+
EXPECT_EQ (0x00u, arr2000[2]);
282+
EXPECT_EQ (0x11u, arr2000[6]);
283+
}
284+
239285
TEST_F (PdoTest, CommParamsSet)
240286
{
241287
const co_obj_t * obj1400 = find_obj (0x1400);

0 commit comments

Comments
 (0)