101 rl_log(
ERROR,
"In read_status: failed to get shared status memory id; " 103 errno, strerror(errno));
108 if (shm_status == (
void*)-1) {
109 rl_log(
ERROR,
"In read_status: failed to map shared status memory; %d " 111 errno, strerror(errno));
116 *status = *shm_status;
135 rl_log(
ERROR,
"In write_status: failed to get shared status memory id; " 137 errno, strerror(errno));
142 if (shm_status == (
void*)-1) {
143 rl_log(
ERROR,
"In write_status: failed to map shared status memory; %d " 145 errno, strerror(errno));
165 if (n % d == d || n % d == 0) {
181 if (signo == SIGQUIT) {
187 if (signo == SIGINT) {
188 signal(signo, SIG_IGN);
189 printf(
"Stopping RocketLogger ...\n");
204 unsigned int value = 0;
205 fp = fopen(filename,
"rt");
210 if (fscanf(fp,
"%x", &value) <= 0) {
226 struct timespec spec_real;
227 struct timespec spec_monotonic;
230 int ret1 = clock_gettime(CLOCK_REALTIME, &spec_real);
231 int ret2 = clock_gettime(CLOCK_MONOTONIC_RAW, &spec_monotonic);
233 if (ret1 < 0 || ret2 < 0) {
238 timestamp_realtime->
sec = (int64_t)spec_real.tv_sec;
239 timestamp_realtime->
nsec = (int64_t)spec_real.tv_nsec;
240 timestamp_monotonic->
sec = (int64_t)spec_monotonic.tv_sec;
241 timestamp_monotonic->
nsec = (int64_t)spec_monotonic.tv_nsec;
252 fscanf(fp,
"%x", &temp);
253 mac_address[0] = (uint8_t)temp;
255 fscanf(fp,
":%x", &temp);
256 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])