100 rl_log(
ERROR,
"In read_status: failed to get shared status memory id; " 102 errno, strerror(errno));
107 if (shm_status == (
void*)-1) {
108 rl_log(
ERROR,
"In read_status: failed to map shared status memory; %d " 110 errno, strerror(errno));
115 *status = *shm_status;
134 rl_log(
ERROR,
"In write_status: failed to get shared status memory id; " 136 errno, strerror(errno));
141 if (shm_status == (
void*)-1) {
142 rl_log(
ERROR,
"In write_status: failed to map shared status memory; %d " 144 errno, strerror(errno));
164 if (n % d == d || n % d == 0) {
180 if (signo == SIGQUIT) {
186 if (signo == SIGINT) {
187 signal(signo, SIG_IGN);
188 printf(
"Stopping RocketLogger ...\n");
203 unsigned int value = 0;
204 fp = fopen(filename,
"rt");
209 if (fscanf(fp,
"%x", &value) <= 0) {
225 struct timespec spec_real;
226 struct timespec spec_monotonic;
229 int ret1 = clock_gettime(CLOCK_REALTIME, &spec_real);
230 int ret2 = clock_gettime(CLOCK_MONOTONIC_RAW, &spec_monotonic);
232 if (ret1 < 0 || ret2 < 0) {
237 timestamp_realtime->
sec = (int64_t)spec_real.tv_sec;
238 timestamp_realtime->
nsec = (int64_t)spec_real.tv_nsec;
239 timestamp_monotonic->
sec = (int64_t)spec_monotonic.tv_sec;
240 timestamp_monotonic->
nsec = (int64_t)spec_monotonic.tv_nsec;
251 fscanf(fp,
"%x", &temp);
252 mac_address[0] = (uint8_t)temp;
254 fscanf(fp,
":%x", &temp);
255 mac_address[i] = (uint8_t)temp;
int write_status(struct rl_status *status)
int is_low_current(int index)
#define MAC_ADDRESS_LENGTH
MAC address length in bytes.
#define MAC_ADDRESS_FILE
File to read MAC address.
struct rl_status status
Current status of RocketLogger.
int64_t sec
Seconds in UNIX time (UTC)
void rl_log(rl_log_type type, const char *format,...)
int read_status(struct rl_status *status)
int read_file_value(char filename[])
#define SHMEM_STATUS_KEY
Key for status shared memory (used for creation)
int ceil_div(int n, int d)
#define NUM_CHANNELS
Maximum number of RocketLogger channels.
#define CHANNEL_ENABLED
Channel sampling enabled.
void get_mac_addr(uint8_t mac_address[MAC_ADDRESS_LENGTH])
#define SHMEM_PERMISSIONS
Permissions for shared memory.
void create_time_stamp(struct time_stamp *timestamp_realtime, struct time_stamp *timestamp_monotonic)
void sig_handler(int signo)
int is_current(int index)
rl_sampling sampling
Sampling state.
int count_channels(int channels[NUM_CHANNELS])