|
RocketLogger
1.0
|
#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... | |
| #define CALIBRATION_FILE "/etc/rocketlogger/calibration.dat" |
| #define CHANNEL_DISABLED 0 |
| #define CHANNEL_ENABLED 1 |
Channel sampling enabled.
Definition at line 178 of file types.h.
Referenced by count_channels(), handle_data_buffer(), merge_currents(), meter_print_buffer(), parse_args(), parse_channels(), pru_sample(), reset_config(), rl_print_config(), setup_channels(), and setup_lead_in().
| #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 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 FAILURE -1 |
Definition at line 53 of file types.h.
Referenced by check_sample_rate(), check_update_rate(), get_pid(), gpio_dir(), gpio_export(), gpio_get_value(), gpio_interrupt(), gpio_set_value(), gpio_setup(), gpio_unexport(), gpio_wait_interrupt(), hw_sample(), main(), parse_args(), parse_channels(), pru_data_setup(), pru_init(), pru_sample(), pwm_setup(), read_calibration(), read_default_config(), read_file_value(), read_status(), remove_sem(), rl_get_status(), rl_read_status(), rl_start(), rl_stop(), set_pid(), set_sem(), unmap_pru_memory(), wait_sem(), write_default_config(), and write_status().
| #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 |
Definition at line 185 of file types.h.
Referenced by handle_data_buffer(), is_current(), is_low_current(), merge_currents(), pru_sample(), setup_channels(), and setup_lead_in().
| #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 |
Definition at line 189 of file types.h.
Referenced by handle_data_buffer(), is_current(), is_low_current(), merge_currents(), pru_sample(), setup_channels(), and setup_lead_in().
| #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" |
| #define MAC_ADDRESS_FILE "/sys/class/net/eth0/address" |
| #define MAX_LOG_FILE_SIZE 1000000 |
| #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 |
| #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 |
| #define NUM_CHANNELS 8 |
Maximum number of RocketLogger channels.
Definition at line 78 of file types.h.
Referenced by count_channels(), handle_data_buffer(), meter_print_buffer(), parse_channels(), print_status(), pru_data_setup(), pru_sample(), read_calibration(), reset_config(), reset_offsets(), reset_scales(), rl_print_config(), and setup_channels().
| #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 |
| #define PID_FILE "/var/run/rocketlogger.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 |
| #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 SUCCESS 1 |
Copyright (c) 2016-2017, ETH Zurich, Computer Engineering Group Return code definitions
Definition at line 50 of file types.h.
Referenced by check_sample_rate(), check_update_rate(), gpio_dir(), gpio_export(), gpio_interrupt(), gpio_set_value(), gpio_setup(), gpio_unexport(), hw_sample(), main(), parse_args(), parse_channels(), print_data(), pru_data_setup(), pru_init(), pru_sample(), pwm_setup(), read_calibration(), read_default_config(), read_status(), remove_sem(), rl_start(), rl_stop(), set_pid(), set_sem(), unmap_pru_memory(), wait_sem(), write_default_config(), 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 enum file_format rl_file_format |
RocketLogger file format definition
| typedef enum log_type rl_log_type |
RocketLogger log file types definition
| typedef enum sampling rl_sampling |
RocketLogger sampling state definition
| typedef enum use_cal rl_use_cal |
RocketLogger calibration definition
| enum file_format |
| enum log_type |
| enum mode |
RocketLogger mode definition
| enum sampling |
| enum state |
| enum use_cal |
| 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().
| 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().