Skip to content

Commit 98eaac0

Browse files
authored
Revert "Include sub-second information in serializer (#69)" (#74)
This reverts commit fcbb28a.
1 parent 5147cf0 commit 98eaac0

5 files changed

Lines changed: 13 additions & 31 deletions

File tree

include/param/param.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ typedef enum {
8686
#define PM_CSP (5 << 16) //! Known as 5 in elfparse and genparamtable
8787
#define PM_KEYCONF (6 << 16) //! Known as 6 in elfparse and genparamtable
8888

89-
/**
90-
* Value to indicate an invalid nsec.
91-
*
92-
* This define should be moved to CSP if CSP will have support for invalid nsec
93-
*/
94-
#define CSP_TIMESTAMP_INVALID_NSEC -1
9589

9690
/**
9791
* Parameter description structure
@@ -146,7 +140,7 @@ typedef struct param_s {
146140

147141
#ifdef PARAM_HAVE_TIMESTAMP
148142
#define PARAM_TIMESTAMP_DECL(_name) \
149-
csp_timestamp_t _timestamp_##_name = { .tv_sec = 0, .tv_nsec = CSP_TIMESTAMP_INVALID_NSEC };
143+
csp_timestamp_t _timestamp_##_name = { .tv_sec = 0, .tv_nsec = 0 };
150144

151145
#define PARAM_TIMESTAMP_INIT(_name) \
152146
.timestamp = &_timestamp_##_name,

meson.build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ if get_option('have_float') == false
2424
conf.set('MPACK_FLOAT', 0)
2525
endif
2626

27-
if get_option('serialize_extended_timestamp') == true
28-
conf.set('EXTENDED_TIMESTAMP', 1)
29-
endif
30-
3127
if get_option('have_fopen') == true
3228
if get_option('list_dynamic') == true
3329
conf.set('MPACK_STDIO', 1)

meson_options.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ option('list_dynamic', type: 'boolean', value: false, description: 'Compile supp
66
option('list_pool', type: 'integer', value: 0, description: 'Compile support for pre-allocated param list (requres sys/queue.h)')
77
option('have_float', type: 'boolean', value: true, description: 'Support float/double')
88
option('num_publishqueues', type: 'integer', value: 0, description: 'Number of param publish queues required')
9-
option('serialize_extended_timestamp', type: 'boolean', value: false, description: 'Include ns part of timestamps when serializing parameters (network incompatible with libparam older than June 2025')
109
option('test', type: 'boolean', value: false, description: 'Build GoogleTest based tests (requires gtest)')

src/param/param_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void param_queue_init(param_queue_t *queue, void *buffer, int buffer_size, int u
3636
queue->used = used;
3737
queue->version = version;
3838
queue->last_timestamp.tv_sec = 0;
39-
queue->last_timestamp.tv_nsec = CSP_TIMESTAMP_INVALID_NSEC;
39+
queue->last_timestamp.tv_nsec = 0;
4040
}
4141

4242
int param_queue_add(param_queue_t *queue, param_t *param, int offset, void *value) {

src/param/param_serializer.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,14 @@ void param_serialize_id(mpack_writer_t *writer, param_t *param, int offset, para
7070
int node_flag = (queue->last_node != node) ? 1 : 0;
7171
#ifdef PARAM_HAVE_TIMESTAMP
7272
int timestamp_flag = (queue->last_timestamp.tv_sec != param->timestamp->tv_sec) ? 1 : 0;
73-
int extendedtimestamp_flag = 0;
74-
#ifdef EXTENDED_TIMESTAMP
75-
extendedtimestamp_flag = (queue->last_timestamp.tv_nsec != param->timestamp->tv_nsec) ? 1 : 0;
76-
#endif /* EXTENDED_TIMESTAMP */
7773
#else
7874
int timestamp_flag = 0;
79-
int extendedtimestamp_flag = 0;
8075
#endif
8176
int extendedid_flag = (param->id > 0x3ff) ? 1 : 0;
8277

83-
uint16_t header = array_flag << PARAM_HEADER_ARRAY_POS
78+
uint16_t header = array_flag << PARAM_HEADER_ARRAY_POS
8479
| node_flag << PARAM_HEADER_NODE_POS
8580
| timestamp_flag << PARAM_HEADER_TIMESTAMP_POS
86-
| extendedtimestamp_flag << PARAM_HEADER_EXTENDEDTIMESTAMP_POS
8781
| extendedid_flag << PARAM_HEADER_EXTENDEDID_POS
8882
|(param->id & PARAM_HEADER_ID_MASK);
8983
header = htobe16(header);
@@ -106,12 +100,6 @@ void param_serialize_id(mpack_writer_t *writer, param_t *param, int offset, para
106100
uint32_t _timestamp = htobe32(param->timestamp->tv_sec);
107101
mpack_write_bytes(writer, (char*) &_timestamp, 4);
108102
}
109-
110-
if (extendedtimestamp_flag) {
111-
queue->last_timestamp.tv_nsec = param->timestamp->tv_nsec;
112-
uint32_t _timestamp_ns = htobe32(param->timestamp->tv_nsec);
113-
mpack_write_bytes(writer, (char*) &_timestamp_ns, 4);
114-
}
115103
#endif
116104

117105
if (extendedid_flag) {
@@ -178,14 +166,19 @@ void param_deserialize_id(mpack_reader_t *reader, int *id, int *node, csp_timest
178166
_timestamp = be32toh(_timestamp);
179167
if (_timestamp != 0) {
180168
queue->last_timestamp.tv_sec = _timestamp;
169+
if (extendedtimestamp_flag) {
170+
uint32_t _timestamp_ns;
171+
mpack_read_bytes(reader, (char*) &_timestamp_ns, 4);
172+
_timestamp_ns = be32toh(_timestamp_ns);
173+
queue->last_timestamp.tv_nsec = _timestamp_ns;
174+
} else {
175+
queue->last_timestamp.tv_nsec = 0;
176+
}
181177
}
182-
}
183-
184-
if (extendedtimestamp_flag) {
178+
} else if (extendedtimestamp_flag) {
179+
/* Invalid header combination, discard header field */
185180
uint32_t _timestamp_ns;
186181
mpack_read_bytes(reader, (char*) &_timestamp_ns, 4);
187-
_timestamp_ns = be32toh(_timestamp_ns);
188-
queue->last_timestamp.tv_nsec = _timestamp_ns;
189182
}
190183
*timestamp = queue->last_timestamp;
191184

0 commit comments

Comments
 (0)