Skip to content

Commit b5a754f

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 845798b commit b5a754f

15 files changed

+119
-87
lines changed

Diff for: include/co_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef uint32_t (*co_access_fn) (
235235
const struct co_obj * obj, /**< object descriptor */
236236
const struct co_entry * entry, /**< entry descriptor */
237237
uint8_t subindex, /**< subindex */
238-
uint32_t * value /**< value to set or get */
238+
uint64_t * value /**< value to set or get */
239239
);
240240

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

Diff for: include/co_obj.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ uint32_t co_od1001_fn (
108108
const co_obj_t * obj,
109109
const co_entry_t * entry,
110110
uint8_t subindex,
111-
uint32_t * value);
111+
uint64_t * value);
112112

113113
/**
114114
* Access function for Pre-defined error field object (1003h)
@@ -128,7 +128,7 @@ uint32_t co_od1003_fn (
128128
const co_obj_t * obj,
129129
const co_entry_t * entry,
130130
uint8_t subindex,
131-
uint32_t * value);
131+
uint64_t * value);
132132

133133
/**
134134
* Access function for COB-ID SYNC message object (1005h)
@@ -148,7 +148,7 @@ uint32_t co_od1005_fn (
148148
const co_obj_t * obj,
149149
const co_entry_t * entry,
150150
uint8_t subindex,
151-
uint32_t * value);
151+
uint64_t * value);
152152

153153
/**
154154
* Access function for Commmunication cycle object (1006h)
@@ -168,7 +168,7 @@ uint32_t co_od1006_fn (
168168
const co_obj_t * obj,
169169
const co_entry_t * entry,
170170
uint8_t subindex,
171-
uint32_t * value);
171+
uint64_t * value);
172172

173173
/**
174174
* Access function for Synchronous window length object (1007h)
@@ -188,7 +188,7 @@ uint32_t co_od1007_fn (
188188
const co_obj_t * obj,
189189
const co_entry_t * entry,
190190
uint8_t subindex,
191-
uint32_t * value);
191+
uint64_t * value);
192192

193193
/**
194194
* Access function for Guard time object (100Ch)
@@ -208,7 +208,7 @@ uint32_t co_od100C_fn (
208208
const co_obj_t * obj,
209209
const co_entry_t * entry,
210210
uint8_t subindex,
211-
uint32_t * value);
211+
uint64_t * value);
212212

213213
/**
214214
* Access function for Life time factor object (100Dh)
@@ -228,7 +228,7 @@ uint32_t co_od100D_fn (
228228
const co_obj_t * obj,
229229
const co_entry_t * entry,
230230
uint8_t subindex,
231-
uint32_t * value);
231+
uint64_t * value);
232232

233233
/**
234234
* Access function for Store Parameters object (1010h)
@@ -248,7 +248,7 @@ uint32_t co_od1010_fn (
248248
const co_obj_t * obj,
249249
const co_entry_t * entry,
250250
uint8_t subindex,
251-
uint32_t * value);
251+
uint64_t * value);
252252

253253
/**
254254
* Access function for Restore Default Parameters object (1011h)
@@ -268,7 +268,7 @@ uint32_t co_od1011_fn (
268268
const co_obj_t * obj,
269269
const co_entry_t * entry,
270270
uint8_t subindex,
271-
uint32_t * value);
271+
uint64_t * value);
272272

273273
/**
274274
* Access function for COB-ID EMCY object (1014h)
@@ -288,7 +288,7 @@ uint32_t co_od1014_fn (
288288
const co_obj_t * obj,
289289
const co_entry_t * entry,
290290
uint8_t subindex,
291-
uint32_t * value);
291+
uint64_t * value);
292292

293293
/**
294294
* Access function for Inhibit time EMCY object (1015h)
@@ -308,7 +308,7 @@ uint32_t co_od1015_fn (
308308
const co_obj_t * obj,
309309
const co_entry_t * entry,
310310
uint8_t subindex,
311-
uint32_t * value);
311+
uint64_t * value);
312312

313313
/**
314314
* Access function for Consumer heartbeat time object (1016h)
@@ -328,7 +328,7 @@ uint32_t co_od1016_fn (
328328
const co_obj_t * obj,
329329
const co_entry_t * entry,
330330
uint8_t subindex,
331-
uint32_t * value);
331+
uint64_t * value);
332332

333333
/**
334334
* Access function for Producer heartbeat time object (1017h)
@@ -348,7 +348,7 @@ uint32_t co_od1017_fn (
348348
const co_obj_t * obj,
349349
const co_entry_t * entry,
350350
uint8_t subindex,
351-
uint32_t * value);
351+
uint64_t * value);
352352

353353
/**
354354
* Access function for Synchronous counter overflow value object (1019h)
@@ -368,7 +368,7 @@ uint32_t co_od1019_fn (
368368
const co_obj_t * obj,
369369
const co_entry_t * entry,
370370
uint8_t subindex,
371-
uint32_t * value);
371+
uint64_t * value);
372372

373373
/**
374374
* Access function for Verify Configuration object (1020h)
@@ -388,7 +388,7 @@ uint32_t co_od1020_fn (
388388
const co_obj_t * obj,
389389
const co_entry_t * entry,
390390
uint8_t subindex,
391-
uint32_t * value);
391+
uint64_t * value);
392392

393393
/**
394394
* Access function for Emergency consumer object (1028h)
@@ -408,7 +408,7 @@ uint32_t co_od1028_fn (
408408
const co_obj_t * obj,
409409
const co_entry_t * entry,
410410
uint8_t subindex,
411-
uint32_t * value);
411+
uint64_t * value);
412412

413413
/**
414414
* Access function for Error behavior object (1029h)
@@ -428,7 +428,7 @@ uint32_t co_od1029_fn (
428428
const co_obj_t * obj,
429429
const co_entry_t * entry,
430430
uint8_t subindex,
431-
uint32_t * value);
431+
uint64_t * value);
432432

433433
/**
434434
* Access function for RPDO communication parameter object (1400h - 15FFh)
@@ -448,7 +448,7 @@ uint32_t co_od1400_fn (
448448
const co_obj_t * obj,
449449
const co_entry_t * entry,
450450
uint8_t subindex,
451-
uint32_t * value);
451+
uint64_t * value);
452452

453453
/**
454454
* Access function for RPDO mapping parameter object (1600h - 17FFh)
@@ -468,7 +468,7 @@ uint32_t co_od1600_fn (
468468
const co_obj_t * obj,
469469
const co_entry_t * entry,
470470
uint8_t subindex,
471-
uint32_t * value);
471+
uint64_t * value);
472472

473473
/**
474474
* Access function for TPDO communication parameter object (1800h - 19FFh)
@@ -488,7 +488,7 @@ uint32_t co_od1800_fn (
488488
const co_obj_t * obj,
489489
const co_entry_t * entry,
490490
uint8_t subindex,
491-
uint32_t * value);
491+
uint64_t * value);
492492

493493
/**
494494
* Access function for RPDO mapping parameter object (1A00h - 1BFFh)
@@ -508,7 +508,7 @@ uint32_t co_od1A00_fn (
508508
const co_obj_t * obj,
509509
const co_entry_t * entry,
510510
uint8_t subindex,
511-
uint32_t * value);
511+
uint64_t * value);
512512

513513
#ifdef __cplusplus
514514
}

Diff for: src/co_emcy.c

+15-8
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

@@ -66,7 +67,7 @@ uint32_t co_od1001_fn (
6667
const co_obj_t * obj,
6768
const co_entry_t * entry,
6869
uint8_t subindex,
69-
uint32_t * value)
70+
uint64_t * value)
7071
{
7172
if (event == OD_EVENT_READ)
7273
*value = co_emcy_error_register_get (net);
@@ -79,14 +80,20 @@ uint32_t co_od1003_fn (
7980
const co_obj_t * obj,
8081
const co_entry_t * entry,
8182
uint8_t subindex,
82-
uint32_t * value)
83+
uint64_t * value)
8384
{
85+
uint32_t retval;
86+
uint32_t v;
8487
switch (event)
8588
{
8689
case OD_EVENT_READ:
87-
return co_emcy_error_get (net, subindex, value);
90+
retval = co_emcy_error_get (net, subindex, &v);
91+
if (retval == 0)
92+
*value = v;
93+
return retval;
8894
case OD_EVENT_WRITE:
89-
return co_emcy_error_set (net, subindex, value);
95+
v = *value;
96+
return co_emcy_error_set (net, subindex, &v);
9097
case OD_EVENT_RESTORE:
9198
net->number_of_errors = 0;
9299
return 0;
@@ -101,7 +108,7 @@ uint32_t co_od1014_fn (
101108
const co_obj_t * obj,
102109
const co_entry_t * entry,
103110
uint8_t subindex,
104-
uint32_t * value)
111+
uint64_t * value)
105112
{
106113
switch (event)
107114
{
@@ -127,7 +134,7 @@ uint32_t co_od1015_fn (
127134
const co_obj_t * obj,
128135
const co_entry_t * entry,
129136
uint8_t subindex,
130-
uint32_t * value)
137+
uint64_t * value)
131138
{
132139
switch (event)
133140
{
@@ -151,7 +158,7 @@ uint32_t co_od1028_fn (
151158
const co_obj_t * obj,
152159
const co_entry_t * entry,
153160
uint8_t subindex,
154-
uint32_t * value)
161+
uint64_t * value)
155162
{
156163
uint32_t cobid;
157164

@@ -186,7 +193,7 @@ uint32_t co_od1029_fn (
186193
const co_obj_t * obj,
187194
const co_entry_t * entry,
188195
uint8_t subindex,
189-
uint32_t * value)
196+
uint64_t * value)
190197
{
191198
switch (event)
192199
{

Diff for: src/co_heartbeat.c

+3-2
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

Diff for: src/co_node_guard.c

+3-2
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
{

Diff for: src/co_od.c

+6-9
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
}
@@ -569,7 +566,7 @@ uint32_t co_od1010_fn (
569566
const co_obj_t * obj,
570567
const co_entry_t * entry,
571568
uint8_t subindex,
572-
uint32_t * value)
569+
uint64_t * value)
573570
{
574571
uint32_t abort;
575572

@@ -630,7 +627,7 @@ uint32_t co_od1011_fn (
630627
const co_obj_t * obj,
631628
const co_entry_t * entry,
632629
uint8_t subindex,
633-
uint32_t * value)
630+
uint64_t * value)
634631
{
635632
uint32_t abort;
636633

@@ -690,7 +687,7 @@ uint32_t co_od1020_fn (
690687
const co_obj_t * obj,
691688
const co_entry_t * entry,
692689
uint8_t subindex,
693-
uint32_t * value)
690+
uint64_t * value)
694691
{
695692
if (subindex == 0 || subindex > obj->max_subindex)
696693
return CO_SDO_ABORT_BAD_SUBINDEX;

0 commit comments

Comments
 (0)