RocketLogger  1.0
types.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include <pthread.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>
#include <prussdrv.h>
#include <pruss_intc_mapping.h>
#include <ncurses.h>
+ Include dependency graph for types.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rl_conf
 
struct  rl_status
 
struct  rl_calibration
 

Macros

#define SUCCESS   1
 
#define UNDEFINED   0
 
#define TIME_OUT   0
 
#define FAILURE   -1
 
#define PID_FILE   "/var/run/rocketlogger.pid"
 Process ID file for background process. More...
 
#define LOG_FILE   "/var/www/log/log.txt"
 Log file name. More...
 
#define MAC_ADDRESS_FILE   "/sys/class/net/eth0/address"
 File to read MAC address. More...
 
#define CALIBRATION_FILE   "/etc/rocketlogger/calibration.dat"
 Calibration file name. More...
 
#define MAX_LOG_FILE_SIZE   1000000
 Log file size in bytes. More...
 
#define SHMEM_STATUS_KEY   1111
 Key for status shared memory (used for creation) More...
 
#define SHMEM_DATA_KEY   4443
 Key for web shared memory (used for creation) More...
 
#define MAX_PATH_LENGTH   100
 Maximum path length in characters. More...
 
#define NUM_CHANNELS   8
 Maximum number of RocketLogger channels. More...
 
#define NUM_I_CHANNELS   2
 Maximum number of RocketLogger current channels. More...
 
#define NUM_V_CHANNELS   4
 Maximum number of RocketLogger voltage channels. More...
 
#define NUM_DIGITAL_INPUTS   6
 Number of RocketLogger digital channels. More...
 
#define METER_UPDATE_RATE   5
 Data update rate in METER mode. More...
 
#define PRU_DIG_SIZE   2
 Size of PRU digital information in bytes. More...
 
#define PRU_BUFFER_STATUS_SIZE   4
 Size of PRU buffer status in bytes. More...
 
#define KSPS   1000
 KSPS <-> SPS conversion factor. More...
 
#define I1L_VALID_BIT   1
 
#define I2L_VALID_BIT   1
 
#define DIGIN1_BIT   2
 
#define DIGIN2_BIT   4
 
#define DIGIN3_BIT   8
 
#define DIGIN4_BIT   2
 
#define DIGIN5_BIT   4
 
#define DIGIN6_BIT   8
 
#define MIN_ADC_RATE   1000
 Minimal ADC sampling rate. More...
 
#define CHANNEL_DISABLED   0
 Channel sampling disabled. More...
 
#define CHANNEL_ENABLED   1
 Channel sampling enabled. More...
 
#define I1H_INDEX   0
 
#define I1L_INDEX   1
 
#define V1_INDEX   2
 
#define V2_INDEX   3
 
#define I2H_INDEX   4
 
#define I2L_INDEX   5
 
#define V3_INDEX   6
 
#define V4_INDEX   7
 
#define DIGITAL_INPUTS_DISABLED   0
 Digital input sampling disabled. More...
 
#define DIGITAL_INPUTS_ENABLED   1
 Digital input sampling ensabled. More...
 
#define SEM_KEY   2222
 Semaphore key (used for set creation) More...
 
#define NUM_SEMS   2
 Number of semaphores in set. More...
 
#define SEM_TIME_OUT   3
 Time out time in seconds, waiting on semaphore read. More...
 
#define SEM_WRITE_TIME_OUT   1
 Time out time in seconds, waiting on semaphore write. More...
 
#define SEM_SET_TIME_OUT   1
 Time out time in seconds, waiting on semaphore value set. More...
 
#define DATA_SEM   0
 Number of data semaphore in set (manages access to shared memory data) More...
 
#define WAIT_SEM   1
 Number of wait semaphore in set (blocks all server processes, until new data is available) More...
 
#define NO_FLAG   0
 No flag. More...
 

Typedefs

typedef enum state rl_state
 
typedef enum sampling rl_sampling
 
typedef enum mode rl_mode
 
typedef enum file_format rl_file_format
 
typedef enum use_cal rl_use_cal
 
typedef enum log_type rl_log_type
 

Enumerations

enum  state { RL_OFF = 0, RL_RUNNING = 1, RL_ERROR = -1 }
 
enum  sampling { SAMPLING_OFF = 0, SAMPLING_ON = 1 }
 
enum  mode {
  LIMIT, CONTINUOUS, METER, STATUS,
  STOPPED, SET_DEFAULT, PRINT_DEFAULT, PRINT_VERSION,
  HELP, NO_MODE
}
 
enum  file_format { NO_FILE = 0, CSV = 1, BIN = 2 }
 
enum  use_cal { CAL_IGNORE = 0, CAL_USE = 1 }
 
enum  log_type { ERROR, WARNING, INFO }
 

Variables

struct rl_status status
 RocketLogger status. More...
 
struct rl_calibration calibration
 Calibration data. More...
 
const char * channel_names [NUM_CHANNELS]
 Channel names. More...
 
const char * digital_input_names [NUM_DIGITAL_INPUTS]
 Digital input names. More...
 
const char * valid_info_names [NUM_I_CHANNELS]
 Range valid information names. More...
 

Macro Definition Documentation

#define CALIBRATION_FILE   "/etc/rocketlogger/calibration.dat"

Calibration file name.

Definition at line 63 of file types.h.

Referenced by read_calibration().

#define CHANNEL_DISABLED   0

Channel sampling disabled.

Definition at line 176 of file types.h.

Referenced by hw_init().

#define CHANNEL_ENABLED   1
#define DATA_SEM   0

Number of data semaphore in set (manages access to shared memory data)

Definition at line 273 of file types.h.

Referenced by handle_data_buffer(), main(), print_data(), pru_sample(), and remove_sem().

#define DIGIN1_BIT   2

Definition at line 100 of file types.h.

#define DIGIN2_BIT   4

Definition at line 101 of file types.h.

#define DIGIN3_BIT   8

Definition at line 102 of file types.h.

#define DIGIN4_BIT   2

Definition at line 103 of file types.h.

#define DIGIN5_BIT   4

Definition at line 104 of file types.h.

#define DIGIN6_BIT   8

Definition at line 105 of file types.h.

#define DIGITAL_INPUTS_DISABLED   0

Digital input sampling disabled.

Definition at line 195 of file types.h.

Referenced by parse_args().

#define DIGITAL_INPUTS_ENABLED   1

Digital input sampling ensabled.

Definition at line 197 of file types.h.

Referenced by handle_data_buffer(), parse_args(), pru_sample(), reset_config(), setup_channels(), and setup_lead_in().

#define I1H_INDEX   0

Channel indices in channel array

Definition at line 184 of file types.h.

Referenced by is_current(), merge_currents(), and pru_sample().

#define I1L_INDEX   1
#define I1L_VALID_BIT   1

Digital channel bit position in PRU digital information

Definition at line 98 of file types.h.

Referenced by meter_print_buffer().

#define I2H_INDEX   4

Definition at line 188 of file types.h.

Referenced by is_current(), merge_currents(), and pru_sample().

#define I2L_INDEX   5
#define I2L_VALID_BIT   1

Definition at line 99 of file types.h.

Referenced by meter_print_buffer().

#define KSPS   1000

KSPS <-> SPS conversion factor.

Definition at line 93 of file types.h.

Referenced by parse_args(), and rl_print_config().

#define LOG_FILE   "/var/www/log/log.txt"

Log file name.

Definition at line 59 of file types.h.

Referenced by rl_log().

#define MAC_ADDRESS_FILE   "/sys/class/net/eth0/address"

File to read MAC address.

Definition at line 61 of file types.h.

Referenced by get_mac_addr().

#define MAX_LOG_FILE_SIZE   1000000

Log file size in bytes.

Definition at line 66 of file types.h.

Referenced by rl_log().

#define MAX_PATH_LENGTH   100

Maximum path length in characters.

Definition at line 76 of file types.h.

Referenced by gpio_dir(), gpio_get_value(), gpio_interrupt(), gpio_set_value(), gpio_wait_interrupt(), print_status(), and pru_sample().

#define METER_UPDATE_RATE   5

Data update rate in METER mode.

Definition at line 86 of file types.h.

Referenced by rl_start().

#define MIN_ADC_RATE   1000

Minimal ADC sampling rate.

Definition at line 108 of file types.h.

Referenced by handle_data_buffer(), hw_init(), pru_sample(), and rl_start().

#define NO_FLAG   0

No flag.

Definition at line 278 of file types.h.

Referenced by set_sem(), and wait_sem().

#define NUM_DIGITAL_INPUTS   6

Number of RocketLogger digital channels.

Definition at line 84 of file types.h.

Referenced by handle_data_buffer(), pru_sample(), setup_channels(), and setup_lead_in().

#define NUM_I_CHANNELS   2

Maximum number of RocketLogger current channels.

Definition at line 80 of file types.h.

Referenced by handle_data_buffer(), print_status(), and rl_print_config().

#define NUM_SEMS   2

Number of semaphores in set.

Definition at line 264 of file types.h.

Referenced by create_sem(), and open_sem().

#define NUM_V_CHANNELS   4

Maximum number of RocketLogger voltage channels.

Definition at line 82 of file types.h.

#define PID_FILE   "/var/run/rocketlogger.pid"

Process ID file for background process.

Definition at line 57 of file types.h.

Referenced by get_pid(), and set_pid().

#define PRU_BUFFER_STATUS_SIZE   4

Size of PRU buffer status in bytes.

Definition at line 90 of file types.h.

Referenced by pru_data_setup(), and pru_sample().

#define PRU_DIG_SIZE   2

Size of PRU digital information in bytes.

Definition at line 88 of file types.h.

Referenced by handle_data_buffer(), meter_print_buffer(), pru_data_setup(), and pru_sample().

#define SEM_KEY   2222

Semaphore key (used for set creation)

Definition at line 262 of file types.h.

Referenced by create_sem(), and open_sem().

#define SEM_SET_TIME_OUT   1

Time out time in seconds, waiting on semaphore value set.

Definition at line 270 of file types.h.

Referenced by set_sem().

#define SEM_TIME_OUT   3

Time out time in seconds, waiting on semaphore read.

Definition at line 266 of file types.h.

Referenced by main(), and print_data().

#define SEM_WRITE_TIME_OUT   1

Time out time in seconds, waiting on semaphore write.

Definition at line 268 of file types.h.

Referenced by handle_data_buffer().

#define SHMEM_DATA_KEY   4443

Key for web shared memory (used for creation)

Definition at line 71 of file types.h.

Referenced by create_web_shm(), and open_web_shm().

#define SHMEM_STATUS_KEY   1111

Key for status shared memory (used for creation)

Definition at line 69 of file types.h.

Referenced by read_status(), and write_status().

#define TIME_OUT   0

Definition at line 52 of file types.h.

Referenced by handle_data_buffer(), set_sem(), and wait_sem().

#define UNDEFINED   0

Definition at line 51 of file types.h.

Referenced by read_default_config().

#define V1_INDEX   2

Definition at line 186 of file types.h.

Referenced by merge_currents().

#define V2_INDEX   3

Definition at line 187 of file types.h.

Referenced by merge_currents().

#define V3_INDEX   6

Definition at line 190 of file types.h.

Referenced by merge_currents().

#define V4_INDEX   7

Definition at line 191 of file types.h.

Referenced by merge_currents().

#define WAIT_SEM   1

Number of wait semaphore in set (blocks all server processes, until new data is available)

Definition at line 275 of file types.h.

Referenced by main(), and pru_sample().

Typedef Documentation

RocketLogger file format definition

typedef enum log_type rl_log_type

RocketLogger log file types definition

typedef enum mode rl_mode

RocketLogger mode definition

typedef enum sampling rl_sampling

RocketLogger sampling state definition

typedef enum state rl_state

RocketLogger state definition

typedef enum use_cal rl_use_cal

RocketLogger calibration definition

Enumeration Type Documentation

RocketLogger file format definition

Enumerator
NO_FILE 

No file.

CSV 

CSV format.

BIN 

Binary format.

Definition at line 149 of file types.h.

enum log_type

RocketLogger log file types definition

Enumerator
ERROR 

Error.

WARNING 

Warning.

INFO 

Information.

Definition at line 166 of file types.h.

enum mode

RocketLogger mode definition

Enumerator
LIMIT 

Limited sampling mode (limited by number of samples to take)

CONTINUOUS 

Continuous sampling mode (in background)

METER 

Meter mode (display current values in terminal)

STATUS 

Get current status of RocketLogger.

STOPPED 

Stop continuous sampling.

SET_DEFAULT 

Set default configuration.

PRINT_DEFAULT 

Print default configuration.

PRINT_VERSION 

Print the RocketLogger Software Stack version.

HELP 

Show help.

NO_MODE 

No mode.

Definition at line 133 of file types.h.

enum sampling

RocketLogger sampling state definition

Enumerator
SAMPLING_OFF 

Not sampling.

SAMPLING_ON 

Sampling.

Definition at line 125 of file types.h.

enum state

RocketLogger state definition

Enumerator
RL_OFF 

Idle.

RL_RUNNING 

Running.

RL_ERROR 

Error.

Definition at line 116 of file types.h.

enum use_cal

RocketLogger calibration definition

Enumerator
CAL_IGNORE 

Ignore calibration.

CAL_USE 

Use calibration (if existing)

Definition at line 158 of file types.h.

Variable Documentation

struct rl_calibration calibration

Calibration data.

Definition at line 284 of file types.h.

Referenced by handle_data_buffer(), meter_print_buffer(), read_calibration(), reset_offsets(), reset_scales(), and rl_read_calibration().

const char* channel_names[NUM_CHANNELS]

Channel names.

Copyright (c) 2016-2017, ETH Zurich, Computer Engineering Group

Definition at line 8 of file file_handling.c.

Referenced by meter_print_buffer(), and setup_channels().

const char* digital_input_names[NUM_DIGITAL_INPUTS]

Digital input names.

Definition at line 10 of file file_handling.c.

Referenced by meter_print_buffer(), and setup_channels().

struct rl_status status

RocketLogger status.

Definition at line 282 of file types.h.

const char* valid_info_names[NUM_I_CHANNELS]

Range valid information names.

Range valid information names.

Definition at line 12 of file file_handling.c.

Referenced by setup_channels().