42 char file_format_names[3][8] = {
"no file",
"csv",
"binary"};
43 char data_aggregation_names[3][10] = {
"none",
"downsample",
"average"};
48 printf(
" Sampling rate: %dSps\n", conf->
sample_rate);
50 printf(
" Data aggregation: %s\n",
55 printf(
" Webserver: enabled\n");
57 printf(
" Webserver: disabled\n");
60 printf(
" Digital inputs: enabled\n");
62 printf(
" Digital inputs: disabled\n");
64 printf(
" File format: %s\n", file_format_names[conf->
file_format]);
66 printf(
" File name: %s\n", conf->
file_name);
69 printf(
" Max file size: %lluMB\n",
73 printf(
" Calibration: ignored\n");
75 printf(
" Channels: ");
84 printf(
" Forced channels: ");
93 printf(
" Sample limit: no limit\n");
106 printf(
"\nRocketLogger IDLE\n\n");
108 printf(
"\nRocketLogger Status: RUNNING\n");
113 printf(
" Calibration time: %s\n", ctime(&time));
115 printf(
" Calibration time: No calibration file found\n");
137 if (strcmp(mode,
"sample") == 0) {
139 }
else if (strcmp(mode,
"cont") == 0) {
141 }
else if (strcmp(mode,
"meter") == 0) {
143 }
else if (strcmp(mode,
"status") == 0) {
145 }
else if (strcmp(mode,
"stop") == 0) {
147 }
else if (strcmp(mode,
"set") == 0) {
149 }
else if (strcmp(mode,
"conf") == 0) {
151 }
else if (strcmp(mode,
"version") == 0 || strcmp(mode,
"--version") == 0) {
153 }
else if (strcmp(mode,
"help") == 0 || strcmp(mode,
"h") == 0 ||
154 strcmp(mode,
"-h") == 0 || strcmp(mode,
"--help") == 0) {
167 if (strcmp(option,
"f") == 0) {
169 }
else if (strcmp(option,
"r") == 0) {
171 }
else if (strcmp(option,
"u") == 0) {
173 }
else if (strcmp(option,
"ch") == 0) {
175 }
else if (strcmp(option,
"fhr") == 0) {
177 }
else if (strcmp(option,
"w") == 0) {
179 }
else if (strcmp(option,
"d") == 0) {
181 }
else if (strcmp(option,
"a") == 0) {
183 }
else if (strcmp(option,
"g") == 0) {
185 }
else if (strcmp(option,
"s") == 0) {
187 }
else if (strcmp(option,
"c") == 0) {
189 }
else if (strcmp(option,
"C") == 0) {
191 }
else if (strcmp(option,
"format") == 0) {
193 }
else if (strcmp(option,
"size") == 0) {
209 if (isdigit(value[0]) && atoi(value) >= 0 && atoi(value) <= 9) {
213 channels[atoi(value)] = 1;
215 }
else if (strcmp(value,
"all") == 0) {
228 for (j = 1; j < 2 * (
NUM_CHANNELS - 1) && value[j] ==
','; j = j + 2) {
231 char* c = &value[j + 1];
232 if (isdigit(c[0]) && atoi(c) >= 0 && atoi(c) <
NUM_CHANNELS) {
233 channels[atoi(c)] = 1;
253 int* set_as_default,
char** file_comment) {
258 *file_comment = NULL;
275 if (argc > 2 && isdigit(argv[2][0]) && atoi(argv[2]) > 0) {
299 atoi(argv[i]) == 0) {
306 for (; i < argc; i++) {
307 if (argv[i][0] ==
'-') {
312 if (isdigit(argv[i][0]) &&
313 atoi(argv[i]) == 0) {
329 if (argc > ++i && isdigit(argv[i][0])) {
330 if (argv[i][strlen(argv[i]) - 1] ==
'k') {
347 if (argc > ++i && isdigit(argv[i][0])) {
376 if (isdigit(c[0]) && atoi(c) < 3 && atoi(c) >= 0) {
390 if (argv[i][1] ==
',') {
392 char* c = &argv[i][2];
393 if (atoi(c) < 3 && atoi(c) > 0) {
408 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
409 atoi(argv[i + 1]) == 0) {
418 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
419 atoi(argv[i + 1]) == 0) {
428 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
429 atoi(argv[i + 1]) == 0) {
439 if (isdigit(argv[i][0]) && atoi(argv[i]) == 0) {
441 }
else if (no_file == 0) {
443 if (strcmp(argv[i],
"none") == 0) {
445 }
else if (strcmp(argv[i],
"average") == 0) {
447 }
else if (strcmp(argv[i],
"downsample") == 0) {
467 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
468 atoi(argv[i + 1]) == 0) {
479 *file_comment = argv[i];
493 if (strcmp(argv[i],
"csv") == 0) {
495 }
else if (strcmp(argv[i],
"bin") == 0) {
511 if (argc > ++i && isdigit(argv[i][0])) {
513 switch (argv[i][strlen(argv[i]) - 1]) {
571 printf(
" rocketlogger mode -[option value]\n");
574 printf(
" sample number Acquires number of samples.\n");
575 printf(
" cont Continuously acquires samples.\n");
576 printf(
" meter Starts RocketLogger Meter.\n");
577 printf(
" status Get status of RocketLogger.\n");
578 printf(
" stop Stops RocketLogger.\n");
579 printf(
" set Set default configuration of RocketLogger " 580 "(use normal options).\n");
581 printf(
" Use 'set 0' to reset the default " 583 printf(
" conf Print default configuration of " 586 printf(
" Options:\n");
587 printf(
" -r rate Acquisition rate selection. Supported " 590 " 1, 10, 100, 1k, 2k, 4k, 8k, 16k, 32k, 64k\n");
591 printf(
" -u update_rate Data update rate selection. Supported " 593 printf(
" 1, 2, 5, 10 (in Hz)\n");
594 printf(
" -ch ch1,ch2,... Channel selection.\n");
595 printf(
" Possible channels ('-ch all' to enable " 597 printf(
" 0: I1H\t\t4: I2H\n");
598 printf(
" 1: I1L\t\t5: I2L\n");
599 printf(
" 2: V1 \t\t6: V3\n");
600 printf(
" 3: V2 \t\t7: V4\n");
601 printf(
" -fhr ch1,ch2 Force high-range.\n");
602 printf(
" 0: no channel, 1: I1, 2: I2\n");
603 printf(
" -c Use calibration, if existing.\n");
604 printf(
" '-c 0' to ignore calibration.\n");
605 printf(
" -f file Stores data to specified file.\n");
606 printf(
" '-f 0' will disable file storing.\n");
607 printf(
" -d Log digital inputs.\n");
608 printf(
" '-d 0' to disable digital input " 610 printf(
" -a Log ambient sensors, if available.\n");
611 printf(
" '-a 0' to disable ambient sensor " 613 printf(
" -g Data aggregation mode for low sample " 615 printf(
" Existing modes: 'average', " 617 printf(
" '-g 0' to disable aggregation/low sample " 619 printf(
" -format format Select file format: csv, bin.\n");
620 printf(
" -size file_size Select max file size (k, m, g can be " 622 printf(
" -C comment Comment stored in file header. Comment is " 624 printf(
" if file saving is disabled.\n");
625 printf(
" -w Enable webserver plotting.\n");
626 printf(
" Use '-w 0' to disable webserver " 628 printf(
" -s Set configuration as default (all except " 631 printf(
" Help/Info:\n");
632 printf(
" help, --help Display this help message.\n");
633 printf(
" version, --version Display the RocketLogger software " 644 printf(
"\nRocketLogger Configuration:\n");
666 strcpy(conf->
file_name,
"/var/www/data/data.rld");
694 rl_log(
ERROR,
"failed to open configuration file");
698 fread(conf,
sizeof(
struct rl_conf), 1, file);
705 rl_log(
WARNING,
"Old or invalid configration file. Using default " 706 "config as fallback.");
727 rl_log(
ERROR,
"failed to create configuration file");
731 fwrite(conf,
sizeof(
struct rl_conf), 1, file);
int force_high_channels[NUM_I_CHANNELS]
Current channels to force to high range.
void rl_print_status(struct rl_status *status)
Limited sampling mode (limited by number of samples to take)
Print default configuration.
Get current status of RocketLogger.
rl_mode mode
Sampling mode.
Stop continuous sampling.
Continuous sampling mode (in background)
void rl_print_version(void)
int check_sample_rate(int sample_rate)
rl_mode get_mode(char *mode)
void rl_print_config(struct rl_conf *conf)
struct rl_status status
Current status of RocketLogger.
int parse_args(int argc, char *argv[], struct rl_conf *conf, int *set_as_default, char **file_comment)
Set configuration as default.
void ambient_set_file_name(struct rl_conf *conf)
int write_default_config(struct rl_conf *conf)
En-/disable data averaging for web server.
const char * GIT_DATE
Date of the of last git commit.
#define RL_CONF_VERSION
RocketLogger configuration structure version number.
void rl_log(rl_log_type type, const char *format,...)
void reset_config(struct rl_conf *conf)
int digital_inputs
En-/disable digital inputs.
#define MAX_PATH_LENGTH
Maximum path length in characters.
struct rl_ambient ambient
Ambient conf.
int enable_web_server
En-/disable plots on web interface.
rl_use_cal calibration
Use/ignore existing calibration.
#define DEFAULT_CONFIG
Default configuration file.
uint64_t samples_taken
Number of samples taken.
Aggregate by averaging data.
int read_default_config(struct rl_conf *conf)
int version
Configuration structure version.
#define NUM_I_CHANNELS
Maximum number of RocketLogger current channels.
Aggregate using downsampling.
int check_update_rate(int update_rate)
int sample_limit
Sample limit (0 for continuous)
#define NUM_CHANNELS
Maximum number of RocketLogger channels.
#define CHANNEL_ENABLED
Channel sampling enabled.
#define KSPS
KSPS <-> SPS conversion factor.
char file_name[MAX_PATH_LENGTH]
Data file name.
Set default configuration.
int channels[NUM_CHANNELS]
Channels to sample.
uint64_t time
Time stamp of calibration run.
Print the RocketLogger Software Stack version.
#define DIGITAL_INPUTS_DISABLED
Digital input sampling disabled.
uint64_t calibration_time
Time stamp of last calibration run.
rl_file_format file_format
File format.
int update_rate
Data update rate.
rl_option get_option(char *option)
Name of data file to write.
char file_name[MAX_PATH_LENGTH]
struct rl_conf conf
Current configuration.
int sample_rate
Sampling rate.
int parse_channels(int channels[], char *value)
Channels to force to high range.
Use calibration (if existing)
const char * GIT_DESCRIPTION
Git code revision description of the code base.
uint64_t max_file_size
Maximum data file size.
void print_config(struct rl_conf *conf)
const char * COMPILE_DATE
Compilation date of the program.
const char * PROJECT_VERSION
The RocketLogger software version string.
Use/ignore existing calibration values.
Meter mode (display current values in terminal)
rl_aggregation aggregation
Aggregation mode (for sampling rates below lowest native one)
#define DIGITAL_INPUTS_ENABLED
Digital input sampling ensabled.