diff --git a/include/param/param.h b/include/param/param.h index 4b31782..dfc872f 100644 --- a/include/param/param.h +++ b/include/param/param.h @@ -86,12 +86,6 @@ typedef enum { #define PM_CSP (5 << 16) //! Known as 5 in elfparse and genparamtable #define PM_KEYCONF (6 << 16) //! Known as 6 in elfparse and genparamtable -/** - * Value to indicate an invalid nsec. - * - * This define should be moved to CSP if CSP will have support for invalid nsec - */ -#define CSP_TIMESTAMP_INVALID_NSEC -1 /** * Parameter description structure @@ -146,7 +140,7 @@ typedef struct param_s { #ifdef PARAM_HAVE_TIMESTAMP #define PARAM_TIMESTAMP_DECL(_name) \ - csp_timestamp_t _timestamp_##_name = { .tv_sec = 0, .tv_nsec = CSP_TIMESTAMP_INVALID_NSEC }; + csp_timestamp_t _timestamp_##_name = { .tv_sec = 0, .tv_nsec = 0 }; #define PARAM_TIMESTAMP_INIT(_name) \ .timestamp = &_timestamp_##_name, diff --git a/meson.build b/meson.build index de243f9..320bb9d 100644 --- a/meson.build +++ b/meson.build @@ -24,10 +24,6 @@ if get_option('have_float') == false conf.set('MPACK_FLOAT', 0) endif -if get_option('serialize_extended_timestamp') == true - conf.set('EXTENDED_TIMESTAMP', 1) -endif - if get_option('have_fopen') == true if get_option('list_dynamic') == true conf.set('MPACK_STDIO', 1) diff --git a/meson_options.txt b/meson_options.txt index 5053071..a1c5765 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,5 +6,4 @@ option('list_dynamic', type: 'boolean', value: false, description: 'Compile supp option('list_pool', type: 'integer', value: 0, description: 'Compile support for pre-allocated param list (requres sys/queue.h)') option('have_float', type: 'boolean', value: true, description: 'Support float/double') option('num_publishqueues', type: 'integer', value: 0, description: 'Number of param publish queues required') -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') option('test', type: 'boolean', value: false, description: 'Build GoogleTest based tests (requires gtest)') diff --git a/src/param/param_queue.c b/src/param/param_queue.c index 237db59..54c2896 100644 --- a/src/param/param_queue.c +++ b/src/param/param_queue.c @@ -36,7 +36,7 @@ void param_queue_init(param_queue_t *queue, void *buffer, int buffer_size, int u queue->used = used; queue->version = version; queue->last_timestamp.tv_sec = 0; - queue->last_timestamp.tv_nsec = CSP_TIMESTAMP_INVALID_NSEC; + queue->last_timestamp.tv_nsec = 0; } int param_queue_add(param_queue_t *queue, param_t *param, int offset, void *value) { diff --git a/src/param/param_serializer.c b/src/param/param_serializer.c index 232f44b..f8434e4 100644 --- a/src/param/param_serializer.c +++ b/src/param/param_serializer.c @@ -70,20 +70,14 @@ void param_serialize_id(mpack_writer_t *writer, param_t *param, int offset, para int node_flag = (queue->last_node != node) ? 1 : 0; #ifdef PARAM_HAVE_TIMESTAMP int timestamp_flag = (queue->last_timestamp.tv_sec != param->timestamp->tv_sec) ? 1 : 0; - int extendedtimestamp_flag = 0; -#ifdef EXTENDED_TIMESTAMP - extendedtimestamp_flag = (queue->last_timestamp.tv_nsec != param->timestamp->tv_nsec) ? 1 : 0; -#endif /* EXTENDED_TIMESTAMP */ #else int timestamp_flag = 0; - int extendedtimestamp_flag = 0; #endif int extendedid_flag = (param->id > 0x3ff) ? 1 : 0; - uint16_t header = array_flag << PARAM_HEADER_ARRAY_POS + uint16_t header = array_flag << PARAM_HEADER_ARRAY_POS | node_flag << PARAM_HEADER_NODE_POS | timestamp_flag << PARAM_HEADER_TIMESTAMP_POS - | extendedtimestamp_flag << PARAM_HEADER_EXTENDEDTIMESTAMP_POS | extendedid_flag << PARAM_HEADER_EXTENDEDID_POS |(param->id & PARAM_HEADER_ID_MASK); header = htobe16(header); @@ -106,12 +100,6 @@ void param_serialize_id(mpack_writer_t *writer, param_t *param, int offset, para uint32_t _timestamp = htobe32(param->timestamp->tv_sec); mpack_write_bytes(writer, (char*) &_timestamp, 4); } - - if (extendedtimestamp_flag) { - queue->last_timestamp.tv_nsec = param->timestamp->tv_nsec; - uint32_t _timestamp_ns = htobe32(param->timestamp->tv_nsec); - mpack_write_bytes(writer, (char*) &_timestamp_ns, 4); - } #endif if (extendedid_flag) { @@ -178,14 +166,19 @@ void param_deserialize_id(mpack_reader_t *reader, int *id, int *node, csp_timest _timestamp = be32toh(_timestamp); if (_timestamp != 0) { queue->last_timestamp.tv_sec = _timestamp; + if (extendedtimestamp_flag) { + uint32_t _timestamp_ns; + mpack_read_bytes(reader, (char*) &_timestamp_ns, 4); + _timestamp_ns = be32toh(_timestamp_ns); + queue->last_timestamp.tv_nsec = _timestamp_ns; + } else { + queue->last_timestamp.tv_nsec = 0; + } } - } - - if (extendedtimestamp_flag) { + } else if (extendedtimestamp_flag) { + /* Invalid header combination, discard header field */ uint32_t _timestamp_ns; mpack_read_bytes(reader, (char*) &_timestamp_ns, 4); - _timestamp_ns = be32toh(_timestamp_ns); - queue->last_timestamp.tv_nsec = _timestamp_ns; } *timestamp = queue->last_timestamp;