Zephyr Scientific Library (zscilib)
measurement.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Linaro
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
40 #ifndef ZSL_MEASUREMENT_H__
41 #define ZSL_MEASUREMENT_H__
42 
43 #include <zsl/zsl.h>
44 #include <zsl/measurement/base.h>
48 #include <zsl/measurement/unit.h>
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
65  union {
66  struct {
68  uint8_t base_type;
70  uint8_t ext_type;
72  union {
73  struct {
75  uint16_t data_format : 3;
77  uint16_t encoding : 4;
79  uint16_t compression : 3;
81  uint16_t timestamp : 3;
83  uint16_t _rsvd : 3;
84  } flags;
86  uint16_t flags_bits;
87  };
88  } filter;
90  uint32_t filter_bits;
91  };
92 
94  union {
95  struct {
100  uint16_t si_unit;
101 
110  uint8_t ctype;
111 
117  int8_t scale_factor;
118  } unit;
120  uint32_t unit_bits;
121  };
122 
124  union {
125  struct {
127  uint16_t len;
128  struct {
130  uint8_t fragment : 2;
132  uint8_t _rsvd : 2;
134  uint8_t samples : 4;
135  };
137  uint8_t sourceid;
138  } srclen;
140  uint32_t srclen_bits;
141  };
142 };
143 
150 
152  void *payload;
153 };
154 
161 };
162 
171 };
172 
179 };
180 
189 };
190 
205 };
206 
211 /*
212  * @addtogroup MES_FUNCTIONS Functions
213  *
214  * @brief Measurement API functions
215  *
216  * @ingroup MEASUREMENT
217  * @{
218  */
219 
225 void zsl_mes_print(struct zsl_measurement *sample);
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
235 #endif /* ZSL_MEASUREMENT_H_ */
zsl_measurement::header
struct zsl_mes_header header
Definition: measurement.h:149
zsl_mes_header::_rsvd
uint16_t _rsvd
Definition: measurement.h:83
zsl_mes_compression
zsl_mes_compression
Definition: measurement.h:174
unit.h
SI unit and scale definitions for zscilib.
zsl_mes_header
Definition: measurement.h:63
zsl_mes_header::unit
struct zsl_mes_header::@5::@13 unit
zsl_mes_header::flags
struct zsl_mes_header::@3::@9::@10::@12 flags
zsl_mes_header::ext_type
uint8_t ext_type
Definition: measurement.h:70
ZSL_MES_TIMESTAMP_EPOCH_32
@ ZSL_MES_TIMESTAMP_EPOCH_32
Definition: measurement.h:196
zsl_mes_header::data_format
uint16_t data_format
Definition: measurement.h:75
zsl_mes_encoding
zsl_mes_encoding
Definition: measurement.h:164
zsl_mes_header::unit_bits
uint32_t unit_bits
Definition: measurement.h:120
zsl_mes_header::si_unit
uint16_t si_unit
The SI unit and default scale used for this measurement. Must be a member of zsl_mes_unit_si.
Definition: measurement.h:100
ZSL_MES_TIMESTAMP_UPTIME_MS_64
@ ZSL_MES_TIMESTAMP_UPTIME_MS_64
Definition: measurement.h:202
ZSL_MES_FRAGMENT_PARTIAL
@ ZSL_MES_FRAGMENT_PARTIAL
Definition: measurement.h:186
ZSL_MES_FORMAT_CBOR
@ ZSL_MES_FORMAT_CBOR
Definition: measurement.h:160
base.h
Standard measureement type definitions for zscilib.
zsl_mes_format
zsl_mes_format
Definition: measurement.h:156
zsl_mes_header::filter
struct zsl_mes_header::@3::@9 filter
zsl_mes_print
void zsl_mes_print(struct zsl_measurement *sample)
Helper function to display the contents of the zsl_measurement.
ZSL_MES_COMPRESSION_NONE
@ ZSL_MES_COMPRESSION_NONE
Definition: measurement.h:176
zsl_mes_header::ctype
uint8_t ctype
The data type that this SI unit is represented by in C. Must be a member of zsl_mes_unit_ctype.
Definition: measurement.h:110
ext_color.h
Extended measuremeent type definitions for ZSL_MES_TYPE_COLOR.
zsl_mes_header::fragment
uint8_t fragment
Definition: measurement.h:130
zsl_mes_header::scale_factor
int8_t scale_factor
The amount to scale the measurement value up or down (10^n), starting from the unit and scale indicat...
Definition: measurement.h:117
zsl_measurement
Measurement packet wrapper.
Definition: measurement.h:147
zsl_mes_header::timestamp
uint16_t timestamp
Definition: measurement.h:81
zsl_mes_header::_rsvd
uint8_t _rsvd
Definition: measurement.h:132
zsl_mes_header::encoding
uint16_t encoding
Definition: measurement.h:77
ZSL_MES_TIMESTAMP_NONE
@ ZSL_MES_TIMESTAMP_NONE
Definition: measurement.h:194
ZSL_MES_FRAGMENT_FINAL
@ ZSL_MES_FRAGMENT_FINAL
Definition: measurement.h:188
zsl_mes_header::srclen_bits
uint32_t srclen_bits
Definition: measurement.h:140
ZSL_MES_FORMAT_NONE
@ ZSL_MES_FORMAT_NONE
Definition: measurement.h:158
zsl_mes_header::srclen
struct zsl_mes_header::@7::@14 srclen
ZSL_MES_TIMESTAMP_UPTIME_US_64
@ ZSL_MES_TIMESTAMP_UPTIME_US_64
Definition: measurement.h:204
zsl_mes_header::len
uint16_t len
Definition: measurement.h:127
zsl_mes_timestamp
zsl_mes_timestamp
Definition: measurement.h:192
zsl_mes_fragment
zsl_mes_fragment
Definition: measurement.h:182
zsl_mes_header::sourceid
uint8_t sourceid
Definition: measurement.h:137
zsl_mes_header::filter_bits
uint32_t filter_bits
Definition: measurement.h:90
ZSL_MES_ENCODING_BASE64
@ ZSL_MES_ENCODING_BASE64
Definition: measurement.h:168
zsl.h
API header file for zscilib.
zsl_measurement::payload
void * payload
Definition: measurement.h:152
ext_temperature.h
Extended measurement type definitions for ZSL_MES_TYPE_TEMPERATURE.
ZSL_MES_ENCODING_NONE
@ ZSL_MES_ENCODING_NONE
Definition: measurement.h:166
ZSL_MES_ENCODING_BASE45
@ ZSL_MES_ENCODING_BASE45
Definition: measurement.h:170
ZSL_MES_TIMESTAMP_UPTIME_MS_32
@ ZSL_MES_TIMESTAMP_UPTIME_MS_32
Definition: measurement.h:200
zsl_mes_header::compression
uint16_t compression
Definition: measurement.h:79
zsl_mes_header::samples
uint8_t samples
Definition: measurement.h:134
ZSL_MES_TIMESTAMP_EPOCH_64
@ ZSL_MES_TIMESTAMP_EPOCH_64
Definition: measurement.h:198
zsl_mes_header::base_type
uint8_t base_type
Definition: measurement.h:68
ZSL_MES_FRAGMENT_NONE
@ ZSL_MES_FRAGMENT_NONE
Definition: measurement.h:184
zsl_mes_header::flags_bits
uint16_t flags_bits
Definition: measurement.h:86
ext_light.h
Extended measurement type definitions for ZSL_MES_TYPE_LIGHT.
ZSL_MES_COMPRESSION_LZ4
@ ZSL_MES_COMPRESSION_LZ4
Definition: measurement.h:178