RocketLogger 2.1.0
calibration.h File Reference
#include <stdint.h>
#include "rl.h"
+ Include dependency graph for calibration.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rl_calibration
 
struct  rl_calibration_file
 

Macros

#define RL_CALIBRATION_FILE_MAGIC   0x434C5225
 Calibration file header magic. More...
 
#define RL_CALIBRATION_FILE_VERSION   0x02
 Calibration file header version. More...
 
#define RL_CALIBRATION_FILE_HEADER_LENGTH   0x10
 Calibration file header length. More...
 

Typedefs

typedef struct rl_calibration rl_calibration_t
 
typedef struct rl_calibration_file rl_calibration_file_t
 

Functions

struct rl_calibration __attribute__ ((packed))
 
void calibration_reset_offsets (void)
 
void calibration_reset_scales (void)
 
int calibration_load (void)
 

Variables

int offsets [RL_CHANNEL_COUNT]
 Channel offsets (in bit) More...
 
double scales [RL_CHANNEL_COUNT]
 Channel scales. More...
 
uint32_t file_magic
 File magic constant. More...
 
uint16_t file_version
 File version number. More...
 
uint16_t header_length
 Total size of the header in bytes. More...
 
uint64_t calibration_time
 Timestamp of the measurements used for calibration generation. More...
 
rl_calibration_t data
 The actual calibration data. More...
 
rl_calibration_t rl_calibration
 Global calibration data structure. More...
 

Macro Definition Documentation

◆ RL_CALIBRATION_FILE_HEADER_LENGTH

#define RL_CALIBRATION_FILE_HEADER_LENGTH   0x10

Calibration file header length.

Definition at line 44 of file calibration.h.

◆ RL_CALIBRATION_FILE_MAGIC

#define RL_CALIBRATION_FILE_MAGIC   0x434C5225

Calibration file header magic.

Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 40 of file calibration.h.

◆ RL_CALIBRATION_FILE_VERSION

#define RL_CALIBRATION_FILE_VERSION   0x02

Calibration file header version.

Definition at line 42 of file calibration.h.

Typedef Documentation

◆ rl_calibration_file_t

Typedef for RocketLogger calibration file structure.

Definition at line 80 of file calibration.h.

◆ rl_calibration_t

Typedef for RocketLogger calibration data.

Definition at line 59 of file calibration.h.

Function Documentation

◆ __attribute__()

struct rl_calibration_file __attribute__ ( (packed)  )

◆ calibration_load()

int calibration_load ( void  )

Load the calibration values from calibration file.

Note
Updates the RocketLogger status. Manually update shared status after loading the calibraion as needed.
Parameters
configPointer to rl_config_t struct.
Returns
Returns 0 on success, negative on failure with errno set accordingly

Definition at line 57 of file calibration.c.

References rl_status::calibration_file, calibration_reset_offsets(), calibration_reset_scales(), rl_calibration_file::calibration_time, rl_status::calibration_time, rl_calibration_file::data, ERROR, rl_calibration_file::file_magic, rl_calibration_file::file_version, rl_calibration_file::header_length, rl_calibration::offsets, RL_CALIBRATION_FILE_HEADER_LENGTH, RL_CALIBRATION_FILE_MAGIC, RL_CALIBRATION_FILE_VERSION, RL_CALIBRATION_SYSTEM_FILE, RL_CALIBRATION_USER_FILE, RL_CONFIG_CHANNEL_DT, rl_log(), RL_LOG_ERROR, rl_calibration::scales, and SUCCESS.

Referenced by hw_sample().

+ Here is the call graph for this function:

◆ calibration_reset_offsets()

void calibration_reset_offsets ( void  )

Reset all calibration offsets to default state (0).

Definition at line 45 of file calibration.c.

References rl_calibration::offsets, and RL_CHANNEL_COUNT.

Referenced by calibration_load(), and hw_sample().

◆ calibration_reset_scales()

void calibration_reset_scales ( void  )

Reset all calibration scales to default state (1).

Definition at line 51 of file calibration.c.

References RL_CHANNEL_COUNT, and rl_calibration::scales.

Referenced by calibration_load(), and hw_sample().

Variable Documentation

◆ calibration_time

uint64_t calibration_time

Timestamp of the measurements used for calibration generation.

Definition at line 7 of file calibration.h.

◆ data

The actual calibration data.

Definition at line 9 of file calibration.h.

Referenced by bme280_read(), bme280_read_calibration(), print_json_bool(), print_json_int64(), rl_file_add_data_block(), and tsl4531_read().

◆ file_magic

uint32_t file_magic

File magic constant.

Definition at line 1 of file calibration.h.

◆ file_version

uint16_t file_version

File version number.

Definition at line 3 of file calibration.h.

◆ header_length

uint16_t header_length

Total size of the header in bytes.

Definition at line 5 of file calibration.h.

◆ offsets

int offsets[RL_CHANNEL_COUNT]

Channel offsets (in bit)

Definition at line 1 of file calibration.h.

◆ rl_calibration

Global calibration data structure.

Global calibration data structure.

Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 43 of file calibration.c.

◆ scales

double scales[RL_CHANNEL_COUNT]

Channel scales.

Definition at line 3 of file calibration.h.