Skip to content

Commit 9c73a28

Browse files
committed
Convert object access function to take 64-bit values
Support programmatic access to values larger than 32 bits. This most straight-forward solution; simply bumping the access function's value pointer to *uint64_t, unfortunately breaks the API. Signed-off-by: Andreas Fritiofson <[email protected]> Change-Id: Id24de582904aeff93f692c46697e1e10f9df3758
1 parent ac8cf72 commit 9c73a28

15 files changed

+119
-87
lines changed

include/co_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ typedef uint32_t (*co_access_fn) (
236236
const struct co_obj * obj, /**< object descriptor */
237237
const struct co_entry * entry, /**< entry descriptor */
238238
uint8_t subindex, /**< subindex */
239-
uint32_t * value /**< value to set or get */
239+
uint64_t * value /**< value to set or get */
240240
);
241241

242242
/** Entry descriptor. Describes a subindex, or a series of subindexes

include/co_obj.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ CO_EXPORT uint32_t co_od1001_fn (
109109
const co_obj_t * obj,
110110
const co_entry_t * entry,
111111
uint8_t subindex,
112-
uint32_t * value);
112+
uint64_t * value);
113113

114114
/**
115115
* Access function for Pre-defined error field object (1003h)
@@ -129,7 +129,7 @@ CO_EXPORT uint32_t co_od1003_fn (
129129
const co_obj_t * obj,
130130
const co_entry_t * entry,
131131
uint8_t subindex,
132-
uint32_t * value);
132+
uint64_t * value);
133133

134134
/**
135135
* Access function for COB-ID SYNC message object (1005h)
@@ -149,7 +149,7 @@ CO_EXPORT uint32_t co_od1005_fn (
149149
const co_obj_t * obj,
150150
const co_entry_t * entry,
151151
uint8_t subindex,
152-
uint32_t * value);
152+
uint64_t * value);
153153

154154
/**
155155
* Access function for Commmunication cycle object (1006h)
@@ -169,7 +169,7 @@ CO_EXPORT uint32_t co_od1006_fn (
169169
const co_obj_t * obj,
170170
const co_entry_t * entry,
171171
uint8_t subindex,
172-
uint32_t * value);
172+
uint64_t * value);
173173

174174
/**
175175
* Access function for Synchronous window length object (1007h)
@@ -189,7 +189,7 @@ CO_EXPORT uint32_t co_od1007_fn (
189189
const co_obj_t * obj,
190190
const co_entry_t * entry,
191191
uint8_t subindex,
192-
uint32_t * value);
192+
uint64_t * value);
193193

194194
/**
195195
* Access function for Guard time object (100Ch)
@@ -209,7 +209,7 @@ CO_EXPORT uint32_t co_od100C_fn (
209209
const co_obj_t * obj,
210210
const co_entry_t * entry,
211211
uint8_t subindex,
212-
uint32_t * value);
212+
uint64_t * value);
213213

214214
/**
215215
* Access function for Life time factor object (100Dh)
@@ -229,7 +229,7 @@ CO_EXPORT uint32_t co_od100D_fn (
229229
const co_obj_t * obj,
230230
const co_entry_t * entry,
231231
uint8_t subindex,
232-
uint32_t * value);
232+
uint64_t * value);
233233

234234
/**
235235
* Access function for Store Parameters object (1010h)
@@ -249,7 +249,7 @@ CO_EXPORT uint32_t co_od1010_fn (
249249
const co_obj_t * obj,
250250
const co_entry_t * entry,
251251
uint8_t subindex,
252-
uint32_t * value);
252+
uint64_t * value);
253253

254254
/**
255255
* Access function for Restore Default Parameters object (1011h)
@@ -269,7 +269,7 @@ CO_EXPORT uint32_t co_od1011_fn (
269269
const co_obj_t * obj,
270270
const co_entry_t * entry,
271271
uint8_t subindex,
272-
uint32_t * value);
272+
uint64_t * value);
273273

274274
/**
275275
* Access function for COB-ID EMCY object (1014h)
@@ -289,7 +289,7 @@ CO_EXPORT uint32_t co_od1014_fn (
289289
const co_obj_t * obj,
290290
const co_entry_t * entry,
291291
uint8_t subindex,
292-
uint32_t * value);
292+
uint64_t * value);
293293

294294
/**
295295
* Access function for Inhibit time EMCY object (1015h)
@@ -309,7 +309,7 @@ CO_EXPORT uint32_t co_od1015_fn (
309309
const co_obj_t * obj,
310310
const co_entry_t * entry,
311311
uint8_t subindex,
312-
uint32_t * value);
312+
uint64_t * value);
313313

314314
/**
315315
* Access function for Consumer heartbeat time object (1016h)
@@ -329,7 +329,7 @@ CO_EXPORT uint32_t co_od1016_fn (
329329
const co_obj_t * obj,
330330
const co_entry_t * entry,
331331
uint8_t subindex,
332-
uint32_t * value);
332+
uint64_t * value);
333333

334334
/**
335335
* Access function for Producer heartbeat time object (1017h)
@@ -349,7 +349,7 @@ CO_EXPORT uint32_t co_od1017_fn (
349349
const co_obj_t * obj,
350350
const co_entry_t * entry,
351351
uint8_t subindex,
352-
uint32_t * value);
352+
uint64_t * value);
353353

354354
/**
355355
* Access function for Synchronous counter overflow value object (1019h)
@@ -369,7 +369,7 @@ CO_EXPORT uint32_t co_od1019_fn (
369369
const co_obj_t * obj,
370370
const co_entry_t * entry,
371371
uint8_t subindex,
372-
uint32_t * value);
372+
uint64_t * value);
373373

374374
/**
375375
* Access function for Verify Configuration object (1020h)
@@ -389,7 +389,7 @@ CO_EXPORT uint32_t co_od1020_fn (
389389
const co_obj_t * obj,
390390
const co_entry_t * entry,
391391
uint8_t subindex,
392-
uint32_t * value);
392+
uint64_t * value);
393393

394394
/**
395395
* Access function for Emergency consumer object (1028h)
@@ -409,7 +409,7 @@ CO_EXPORT uint32_t co_od1028_fn (
409409
const co_obj_t * obj,
410410
const co_entry_t * entry,
411411
uint8_t subindex,
412-
uint32_t * value);
412+
uint64_t * value);
413413

414414
/**
415415
* Access function for Error behavior object (1029h)
@@ -429,7 +429,7 @@ CO_EXPORT uint32_t co_od1029_fn (
429429
const co_obj_t * obj,
430430
const co_entry_t * entry,
431431
uint8_t subindex,
432-
uint32_t * value);
432+
uint64_t * value);
433433

434434
/**
435435
* Access function for RPDO communication parameter object (1400h - 15FFh)
@@ -449,7 +449,7 @@ CO_EXPORT uint32_t co_od1400_fn (
449449
const co_obj_t * obj,
450450
const co_entry_t * entry,
451451
uint8_t subindex,
452-
uint32_t * value);
452+
uint64_t * value);
453453

454454
/**
455455
* Access function for RPDO mapping parameter object (1600h - 17FFh)
@@ -469,7 +469,7 @@ CO_EXPORT uint32_t co_od1600_fn (
469469
const co_obj_t * obj,
470470
const co_entry_t * entry,
471471
uint8_t subindex,
472-
uint32_t * value);
472+
uint64_t * value);
473473

474474
/**
475475
* Access function for TPDO communication parameter object (1800h - 19FFh)
@@ -489,7 +489,7 @@ CO_EXPORT uint32_t co_od1800_fn (
489489
const co_obj_t * obj,
490490
const co_entry_t * entry,
491491
uint8_t subindex,
492-
uint32_t * value);
492+
uint64_t * value);
493493

494494
/**
495495
* Access function for RPDO mapping parameter object (1A00h - 1BFFh)
@@ -509,7 +509,7 @@ CO_EXPORT uint32_t co_od1A00_fn (
509509
const co_obj_t * obj,
510510
const co_entry_t * entry,
511511
uint8_t subindex,
512-
uint32_t * value);
512+
uint64_t * value);
513513

514514
#ifdef __cplusplus
515515
}

src/co_emcy.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "co_nmt.h"
2424
#include "co_sdo.h"
2525
#include "co_util.h"
26+
#include "co_obj.h"
2627

2728
#include <string.h>
2829

@@ -84,7 +85,7 @@ uint32_t co_od1001_fn (
8485
const co_obj_t * obj,
8586
const co_entry_t * entry,
8687
uint8_t subindex,
87-
uint32_t * value)
88+
uint64_t * value)
8889
{
8990
if (event == OD_EVENT_READ)
9091
*value = co_emcy_error_register_get (net);
@@ -97,14 +98,20 @@ uint32_t co_od1003_fn (
9798
const co_obj_t * obj,
9899
const co_entry_t * entry,
99100
uint8_t subindex,
100-
uint32_t * value)
101+
uint64_t * value)
101102
{
103+
uint32_t retval;
104+
uint32_t v;
102105
switch (event)
103106
{
104107
case OD_EVENT_READ:
105-
return co_emcy_error_get (net, subindex, value);
108+
retval = co_emcy_error_get (net, subindex, &v);
109+
if (retval == 0)
110+
*value = v;
111+
return retval;
106112
case OD_EVENT_WRITE:
107-
return co_emcy_error_set (net, subindex, value);
113+
v = *value;
114+
return co_emcy_error_set (net, subindex, &v);
108115
case OD_EVENT_RESTORE:
109116
net->number_of_errors = 0;
110117
return 0;
@@ -119,7 +126,7 @@ uint32_t co_od1014_fn (
119126
const co_obj_t * obj,
120127
const co_entry_t * entry,
121128
uint8_t subindex,
122-
uint32_t * value)
129+
uint64_t * value)
123130
{
124131
switch (event)
125132
{
@@ -145,7 +152,7 @@ uint32_t co_od1015_fn (
145152
const co_obj_t * obj,
146153
const co_entry_t * entry,
147154
uint8_t subindex,
148-
uint32_t * value)
155+
uint64_t * value)
149156
{
150157
switch (event)
151158
{
@@ -169,7 +176,7 @@ uint32_t co_od1028_fn (
169176
const co_obj_t * obj,
170177
const co_entry_t * entry,
171178
uint8_t subindex,
172-
uint32_t * value)
179+
uint64_t * value)
173180
{
174181
uint32_t cobid;
175182

@@ -204,7 +211,7 @@ uint32_t co_od1029_fn (
204211
const co_obj_t * obj,
205212
const co_entry_t * entry,
206213
uint8_t subindex,
207-
uint32_t * value)
214+
uint64_t * value)
208215
{
209216
switch (event)
210217
{

src/co_heartbeat.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "co_sdo.h"
2424
#include "co_emcy.h"
2525
#include "co_util.h"
26+
#include "co_obj.h"
2627

2728
#include <string.h>
2829

@@ -32,7 +33,7 @@ uint32_t co_od1017_fn (
3233
const co_obj_t * obj,
3334
const co_entry_t * entry,
3435
uint8_t subindex,
35-
uint32_t * value)
36+
uint64_t * value)
3637
{
3738
switch (event)
3839
{
@@ -56,7 +57,7 @@ uint32_t co_od1016_fn (
5657
const co_obj_t * obj,
5758
const co_entry_t * entry,
5859
uint8_t subindex,
59-
uint32_t * value)
60+
uint64_t * value)
6061
{
6162
co_heartbeat_t * heartbeat = &net->heartbeat[subindex - 1];
6263

src/co_node_guard.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
#include "co_sdo.h"
2424
#include "co_emcy.h"
2525
#include "co_util.h"
26+
#include "co_obj.h"
2627

2728
uint32_t co_od100C_fn (
2829
co_net_t * net,
2930
od_event_t event,
3031
const co_obj_t * obj,
3132
const co_entry_t * entry,
3233
uint8_t subindex,
33-
uint32_t * value)
34+
uint64_t * value)
3435
{
3536
switch (event)
3637
{
@@ -54,7 +55,7 @@ uint32_t co_od100D_fn (
5455
const co_obj_t * obj,
5556
const co_entry_t * entry,
5657
uint8_t subindex,
57-
uint32_t * value)
58+
uint64_t * value)
5859
{
5960
switch (event)
6061
{

src/co_od.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "co_od.h"
2020
#include "co_sdo.h"
2121
#include "co_util.h"
22+
#include "co_obj.h"
2223

2324
#include <string.h>
2425
#include <inttypes.h>
@@ -139,15 +140,12 @@ uint32_t co_od_get_value (
139140

140141
if (obj->access)
141142
{
142-
uint32_t v;
143-
144143
/* Call object access function. For subindex 0, function may
145144
return BAD_SUBINDEX to indicate that it did not handle the
146145
access. */
147-
abort = obj->access (net, OD_EVENT_READ, obj, entry, subindex, &v);
146+
abort = obj->access (net, OD_EVENT_READ, obj, entry, subindex, value);
148147
if (!(subindex == 0 && abort == CO_SDO_ABORT_BAD_SUBINDEX))
149148
{
150-
*value = v;
151149
return abort;
152150
}
153151
}
@@ -218,9 +216,8 @@ uint32_t co_od_set_value (
218216
if (obj->access)
219217
{
220218
uint32_t result;
221-
uint32_t v = value;
222219

223-
result = obj->access (net, OD_EVENT_WRITE, obj, entry, subindex, &v);
220+
result = obj->access (net, OD_EVENT_WRITE, obj, entry, subindex, &value);
224221
co_od_notify (net, obj, entry, subindex);
225222
return result;
226223
}
@@ -586,7 +583,7 @@ uint32_t co_od1010_fn (
586583
const co_obj_t * obj,
587584
const co_entry_t * entry,
588585
uint8_t subindex,
589-
uint32_t * value)
586+
uint64_t * value)
590587
{
591588
uint32_t abort;
592589

@@ -647,7 +644,7 @@ uint32_t co_od1011_fn (
647644
const co_obj_t * obj,
648645
const co_entry_t * entry,
649646
uint8_t subindex,
650-
uint32_t * value)
647+
uint64_t * value)
651648
{
652649
uint32_t abort;
653650

@@ -707,7 +704,7 @@ uint32_t co_od1020_fn (
707704
const co_obj_t * obj,
708705
const co_entry_t * entry,
709706
uint8_t subindex,
710-
uint32_t * value)
707+
uint64_t * value)
711708
{
712709
if (subindex == 0 || subindex > obj->max_subindex)
713710
return CO_SDO_ABORT_BAD_SUBINDEX;

0 commit comments

Comments
 (0)