41 char file_format_names[3][8] = {
"no file",
"csv",
"binary"};
42 char data_aggregation_names[3][10] = {
"none",
"downsample",
"average"};
47 printf(
" Sampling rate: %dSps\n", conf->
sample_rate);
49 printf(
" Data aggregation: %s\n",
54 printf(
" Webserver: enabled\n");
56 printf(
" Webserver: disabled\n");
59 printf(
" Digital inputs: enabled\n");
61 printf(
" Digital inputs: disabled\n");
63 printf(
" File format: %s\n", file_format_names[conf->
file_format]);
65 printf(
" File name: %s\n", conf->
file_name);
68 printf(
" Max file size: %lluMB\n",
72 printf(
" Calibration: ignored\n");
74 printf(
" Channels: ");
83 printf(
" Forced channels: ");
92 printf(
" Sample limit: no limit\n");
105 printf(
"\nRocketLogger IDLE\n\n");
107 printf(
"\nRocketLogger Status: RUNNING\n");
112 printf(
" Calibration time: %s\n", ctime(&time));
114 printf(
" Calibration time: No calibration file found\n");
124 printf(
"RocketLogger Software Stack version " RL_VERSION "\n");
140 if (strcmp(mode,
"sample") == 0) {
142 }
else if (strcmp(mode,
"cont") == 0) {
144 }
else if (strcmp(mode,
"meter") == 0) {
146 }
else if (strcmp(mode,
"status") == 0) {
148 }
else if (strcmp(mode,
"stop") == 0) {
150 }
else if (strcmp(mode,
"set") == 0) {
152 }
else if (strcmp(mode,
"conf") == 0) {
154 }
else if (strcmp(mode,
"version") == 0 || strcmp(mode,
"--version") == 0) {
156 }
else if (strcmp(mode,
"help") == 0 || strcmp(mode,
"h") == 0 ||
157 strcmp(mode,
"-h") == 0 || strcmp(mode,
"--help") == 0) {
170 if (strcmp(option,
"f") == 0) {
172 }
else if (strcmp(option,
"r") == 0) {
174 }
else if (strcmp(option,
"u") == 0) {
176 }
else if (strcmp(option,
"ch") == 0) {
178 }
else if (strcmp(option,
"fhr") == 0) {
180 }
else if (strcmp(option,
"w") == 0) {
182 }
else if (strcmp(option,
"d") == 0) {
184 }
else if (strcmp(option,
"a") == 0) {
186 }
else if (strcmp(option,
"g") == 0) {
188 }
else if (strcmp(option,
"s") == 0) {
190 }
else if (strcmp(option,
"c") == 0) {
192 }
else if (strcmp(option,
"C") == 0) {
194 }
else if (strcmp(option,
"format") == 0) {
196 }
else if (strcmp(option,
"size") == 0) {
212 if (isdigit(value[0]) && atoi(value) >= 0 && atoi(value) <= 9) {
216 channels[atoi(value)] = 1;
218 }
else if (strcmp(value,
"all") == 0) {
231 for (j = 1; j < 2 * (
NUM_CHANNELS - 1) && value[j] ==
','; j = j + 2) {
234 char* c = &value[j + 1];
235 if (isdigit(c[0]) && atoi(c) >= 0 && atoi(c) <
NUM_CHANNELS) {
236 channels[atoi(c)] = 1;
256 int* set_as_default,
char** file_comment) {
261 *file_comment = NULL;
278 if (argc > 2 && isdigit(argv[2][0]) && atoi(argv[2]) > 0) {
302 atoi(argv[i]) == 0) {
309 for (; i < argc; i++) {
310 if (argv[i][0] ==
'-') {
315 if (isdigit(argv[i][0]) &&
316 atoi(argv[i]) == 0) {
332 if (argc > ++i && isdigit(argv[i][0])) {
333 if (argv[i][strlen(argv[i]) - 1] ==
'k') {
350 if (argc > ++i && isdigit(argv[i][0])) {
379 if (isdigit(c[0]) && atoi(c) < 3 && atoi(c) >= 0) {
393 if (argv[i][1] ==
',') {
395 char* c = &argv[i][2];
396 if (atoi(c) < 3 && atoi(c) > 0) {
411 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
412 atoi(argv[i + 1]) == 0) {
421 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
422 atoi(argv[i + 1]) == 0) {
431 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
432 atoi(argv[i + 1]) == 0) {
442 if (isdigit(argv[i][0]) && atoi(argv[i]) == 0) {
444 }
else if (no_file == 0) {
446 if (strcmp(argv[i],
"none") == 0) {
448 }
else if (strcmp(argv[i],
"average") == 0) {
450 }
else if (strcmp(argv[i],
"downsample") == 0) {
470 if (argc > i + 1 && isdigit(argv[i + 1][0]) &&
471 atoi(argv[i + 1]) == 0) {
482 *file_comment = argv[i];
496 if (strcmp(argv[i],
"csv") == 0) {
498 }
else if (strcmp(argv[i],
"bin") == 0) {
514 if (argc > ++i && isdigit(argv[i][0])) {
516 switch (argv[i][strlen(argv[i]) - 1]) {
574 printf(
" rocketlogger mode -[option value]\n");
577 printf(
" sample number Acquires number of samples.\n");
578 printf(
" cont Continuously acquires samples.\n");
579 printf(
" meter Starts RocketLogger Meter.\n");
580 printf(
" status Get status of RocketLogger.\n");
581 printf(
" stop Stops RocketLogger.\n");
582 printf(
" set Set default configuration of RocketLogger " 583 "(use normal options).\n");
584 printf(
" Use 'set 0' to reset the default " 586 printf(
" conf Print default configuration of " 589 printf(
" Options:\n");
590 printf(
" -r rate Acquisition rate selection. Supported " 593 " 1, 10, 100, 1k, 2k, 4k, 8k, 16k, 32k, 64k\n");
594 printf(
" -u update_rate Data update rate selection. Supported " 596 printf(
" 1, 2, 5, 10 (in Hz)\n");
597 printf(
" -ch ch1,ch2,... Channel selection.\n");
598 printf(
" Possible channels ('-ch all' to enable " 600 printf(
" 0: I1H\t\t4: I2H\n");
601 printf(
" 1: I1L\t\t5: I2L\n");
602 printf(
" 2: V1 \t\t6: V3\n");
603 printf(
" 3: V2 \t\t7: V4\n");
604 printf(
" -fhr ch1,ch2 Force high-range.\n");
605 printf(
" 0: no channel, 1: I1, 2: I2\n");
606 printf(
" -c Use calibration, if existing.\n");
607 printf(
" '-c 0' to ignore calibration.\n");
608 printf(
" -f file Stores data to specified file.\n");
609 printf(
" '-f 0' will disable file storing.\n");
610 printf(
" -d Log digital inputs.\n");
611 printf(
" '-d 0' to disable digital input " 613 printf(
" -a Log ambient sensors, if available.\n");
614 printf(
" '-a 0' to disable ambient sensor " 616 printf(
" -g Data aggregation mode for low sample " 618 printf(
" Existing modes: 'average', " 620 printf(
" '-g 0' to disable aggregation/low sample " 622 printf(
" -format format Select file format: csv, bin.\n");
623 printf(
" -size file_size Select max file size (k, m, g can be " 625 printf(
" -C comment Comment stored in file header. Comment is " 627 printf(
" if file saving is disabled.\n");
628 printf(
" -w Enable webserver plotting.\n");
629 printf(
" Use '-w 0' to disable webserver " 631 printf(
" -s Set configuration as default (all except " 634 printf(
" Help/Info:\n");
635 printf(
" help, --help Display this help message.\n");
636 printf(
" version, --version Display the RocketLogger software " 647 printf(
"\nRocketLogger Configuration:\n");
669 strcpy(conf->
file_name,
"/var/www/data/data.rld");
697 rl_log(
ERROR,
"failed to open configuration file");
701 fread(conf,
sizeof(
struct rl_conf), 1, file);
708 rl_log(
WARNING,
"Old or invalid configration file. Using default " 709 "config as fallback.");
730 rl_log(
ERROR,
"failed to create configuration file");
734 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)
#define RL_VERSION
The RocketLogger software version string.
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.
#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)
uint64_t max_file_size
Maximum data file size.
void print_config(struct rl_conf *conf)
char * rl_get_version(void)
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.