41 #include <sys/statvfs.h>
83 if (n % d == d || n % d == 0) {
93 struct timespec spec_real;
94 struct timespec spec_monotonic;
97 int ret1 = clock_gettime(CLOCK_REALTIME, &spec_real);
98 int ret2 = clock_gettime(CLOCK_MONOTONIC_RAW, &spec_monotonic);
100 if (ret1 < 0 || ret2 < 0) {
106 timestamp_realtime->
sec = (int64_t)spec_real.tv_sec;
107 timestamp_realtime->
nsec = (int64_t)spec_real.tv_nsec;
108 timestamp_monotonic->
sec = (int64_t)spec_monotonic.tv_sec;
109 timestamp_monotonic->
nsec = (int64_t)spec_monotonic.tv_nsec;
116 fscanf(fp,
"%x", &temp);
117 mac_address[0] = (uint8_t)temp;
119 fscanf(fp,
":%x", &temp);
120 mac_address[i] = (uint8_t)temp;
127 int ret = statvfs(path, &stat);
130 "failed getting free file system size; %d message: %s", errno,
134 return (uint64_t)stat.f_bavail * (uint64_t)stat.f_bsize;
139 int ret = statvfs(path, &stat);
142 "failed getting total file system size; %d message: %s", errno,
146 return ((uint64_t)stat.f_blocks * (uint64_t)stat.f_frsize);
160 if (isprint(*str) || isspace(*str)) {
171 for (
int i = 0; i < length; i++) {
175 printf(
"%d",
data[i] ? 1 : 0);
182 for (
int i = 0; i < length; i++) {
186 printf(
"%lld",
data[i]);
191 int snprintfcat(
char *
const buffer,
size_t length,
char const *format, ...) {
193 va_start(args, format);
194 char *
const buffer_next = buffer + strlen(buffer);
195 size_t length_next = length - strlen(buffer);
196 int res = vsnprintf(buffer_next, length_next, format, args);
rl_calibration_t data
The actual calibration data.
int rl_log(rl_log_level_t log_level, char const *const format,...)
#define RL_CONFIG_CHANNEL_I1H
#define RL_CONFIG_CHANNEL_I2L
#define RL_CONFIG_CHANNEL_I2H
#define RL_CONFIG_CHANNEL_V4
#define RL_CONFIG_CHANNEL_V3
#define RL_CONFIG_CHANNEL_V2
#define RL_CONFIG_CHANNEL_I1L
#define RL_CHANNEL_COUNT
Number of RocketLogger analog channels.
#define RL_CONFIG_CHANNEL_V1
Configuration channel indexes.
int64_t sec
Seconds in UNIX time (UTC)
bool is_current(int index)
int64_t fs_space_free(char const *const path)
int count_channels(bool const channels[RL_CHANNEL_COUNT])
bool is_printable_string(char const *str)
int div_ceil(int n, int d)
int64_t fs_space_total(char const *const path)
void create_time_stamp(rl_timestamp_t *const timestamp_realtime, rl_timestamp_t *const timestamp_monotonic)
void get_mac_addr(uint8_t mac_address[MAC_ADDRESS_LENGTH])
bool is_low_current(int index)
void print_json_bool(bool const *const data, const int length)
bool is_empty_string(char const *str)
bool is_voltage(int index)
int snprintfcat(char *const buffer, size_t length, char const *format,...)
void print_json_int64(int64_t const *const data, const int length)
#define MAC_ADDRESS_LENGTH
MAC address length in bytes.
#define MAC_ADDRESS_FILE
File to read MAC address.