RocketLogger  1.0
calibration.c
Go to the documentation of this file.
1 
5 #include "calibration.h"
6 
7 // reset calibration
11 void reset_offsets(void) {
12  int i;
13  for (i=0; i< NUM_CHANNELS; i++) {
14  calibration.offsets[i] = 0;
15  }
16 }
17 
21 void reset_scales(void) {
22  int i;
23  for (i=0; i< NUM_CHANNELS; i++) {
24  calibration.scales[i] = 1;
25  }
26 }
27 
33 int read_calibration(struct rl_conf* conf) {
34 
35  // open calibration file
36  FILE* file = fopen(CALIBRATION_FILE, "r");
37  if(file == NULL) {
38  // no calibration file available
39  reset_offsets();
40  reset_scales();
42  return FAILURE;
43  }
44  // read calibration
45  fread(&calibration, sizeof(struct rl_calibration), 1, file);
46 
47  // reset calibration, if ignored
48  if(conf->calibration == CAL_IGNORE) {
49  reset_offsets();
50  reset_scales();
51  }
52 
53  // store timestamp to conf and status
55 
56  // calculate values for high rates
57  if(conf->sample_rate == 32000 || conf->sample_rate == 64000) {
58  int i;
59  for (i=0; i<NUM_CHANNELS; i++) {
62  }
63  }
64 
65  //close file
66  fclose(file);
67 
68  return SUCCESS;
69 }
70 
int offsets[NUM_CHANNELS]
Channel offsets (in bit)
Definition: types.h:254
double scales[NUM_CHANNELS]
Channel scalings.
Definition: types.h:256
#define FAILURE
Definition: types.h:53
#define SUCCESS
Definition: types.h:50
struct rl_status status
Current status of RocketLogger.
Definition: rl_server.c:42
#define CALIBRATION_FILE
Calibration file name.
Definition: types.h:63
rl_use_cal calibration
Use/ignore existing calibration.
Definition: types.h:220
Definition: types.h:202
#define NUM_CHANNELS
Maximum number of RocketLogger channels.
Definition: types.h:78
void reset_scales(void)
Definition: calibration.c:21
uint64_t time
Time stamp of calibration run.
Definition: types.h:252
uint64_t calibration_time
Time stamp of last calibration run.
Definition: types.h:244
void reset_offsets(void)
Definition: calibration.c:11
int sample_rate
Sampling rate.
Definition: types.h:206
Ignore calibration.
Definition: types.h:159
int read_calibration(struct rl_conf *conf)
Definition: calibration.c:33
struct rl_calibration calibration
Calibration data.
Definition: types.h:284