@@ -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