|
RocketLogger
1.1.6
|
#include <ctype.h>#include <errno.h>#include <stdarg.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <pthread.h>#include <signal.h>#include <sys/mman.h>#include <sys/shm.h>#include <fcntl.h>#include <poll.h>#include <sys/stat.h>#include <sys/time.h>#include <time.h>#include <pruss_intc_mapping.h>#include <prussdrv.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_ambient |
| 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 | SHMEM_PERMISSIONS 0666 |
| Permissions for shared memory. More... | |
| #define | MAX_PATH_LENGTH 256 |
| 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 | RL_CONF_VERSION 0x01 |
| RocketLogger configuration structure version number. More... | |
| #define | AMBIENT_MAX_SENSOR_COUNT 128 |
| #define | AMBIENT_DISABLED 0 |
| #define | AMBIENT_ENABLED 1 |
| #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 |
| #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 aggregation | rl_aggregation |
| 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 | aggregation { AGGREGATE_NONE = 0, AGGREGATE_DOWNSAMPLE = 1, AGGREGATE_AVERAGE = 2 } |
| 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_ambient | ambient |
| 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 AMBIENT_DISABLED 0 |
Definition at line 210 of file types.h.
Referenced by parse_args(), reset_config(), and rl_start().
| #define AMBIENT_ENABLED 1 |
Definition at line 211 of file types.h.
Referenced by hw_close(), hw_init(), hw_sample(), parse_args(), pru_sample(), and rl_start().
| #define CALIBRATION_FILE "/etc/rocketlogger/calibration.dat" |
| #define CHANNEL_DISABLED 0 |
| #define CHANNEL_ENABLED 1 |
Channel sampling enabled.
Definition at line 223 of file types.h.
Referenced by count_channels(), file_handle_data(), file_setup_channels(), file_setup_lead_in(), meter_print_buffer(), parse_args(), parse_channels(), pru_sample(), reset_config(), rl_print_config(), web_handle_data(), and web_merge_currents().
| #define DATA_SEM 0 |
Number of data semaphore in set (manages access to shared memory data)
Definition at line 323 of file types.h.
Referenced by main(), print_data(), pru_sample(), and web_handle_data().
| #define DIGITAL_INPUTS_DISABLED 0 |
Digital input sampling disabled.
Definition at line 240 of file types.h.
Referenced by parse_args().
| #define DIGITAL_INPUTS_ENABLED 1 |
Digital input sampling ensabled.
Definition at line 242 of file types.h.
Referenced by file_handle_data(), file_setup_channels(), file_setup_lead_in(), parse_args(), pru_sample(), reset_config(), and web_handle_data().
| #define FAILURE -1 |
Definition at line 78 of file types.h.
Referenced by BME280_init(), BME280_read(), BME280_readCalibration(), BME280_setParameters(), 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(), pru_unmap_memory(), 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(), TSL4531_init(), TSL4531_read(), TSL4531_sendRange(), TSL4531_setParameters(), TSL4531_setRange(), wait_sem(), write_default_config(), and write_status().
| #define I1H_INDEX 0 |
Channel indices in channel array
Definition at line 229 of file types.h.
Referenced by is_current(), pru_sample(), and web_merge_currents().
| #define I1L_INDEX 1 |
Definition at line 230 of file types.h.
Referenced by file_handle_data(), file_setup_channels(), file_setup_lead_in(), is_current(), is_low_current(), pru_sample(), web_handle_data(), and web_merge_currents().
| #define I1L_VALID_BIT 1 |
Digital channel bit position in PRU digital information
Definition at line 124 of file types.h.
Referenced by meter_print_buffer().
| #define I2H_INDEX 4 |
Definition at line 233 of file types.h.
Referenced by is_current(), pru_sample(), and web_merge_currents().
| #define I2L_INDEX 5 |
Definition at line 234 of file types.h.
Referenced by file_handle_data(), file_setup_channels(), file_setup_lead_in(), is_current(), is_low_current(), pru_sample(), web_handle_data(), and web_merge_currents().
| #define I2L_VALID_BIT 1 |
Definition at line 125 of file types.h.
Referenced by meter_print_buffer().
| #define KSPS 1000 |
KSPS <-> SPS conversion factor.
Definition at line 119 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 256 |
Maximum path length in characters.
Definition at line 102 of file types.h.
Referenced by ambient_set_file_name(), gpio_dir(), gpio_get_value(), gpio_interrupt(), gpio_set_value(), gpio_wait_interrupt(), parse_args(), print_status(), and pru_sample().
| #define METER_UPDATE_RATE 5 |
| #define MIN_ADC_RATE 1000 |
Minimal ADC sampling rate.
Definition at line 134 of file types.h.
Referenced by file_handle_data(), hw_init(), pru_sample(), and rl_start().
| #define NO_FLAG 0 |
| #define NUM_CHANNELS 8 |
Maximum number of RocketLogger channels.
Definition at line 104 of file types.h.
Referenced by count_channels(), file_handle_data(), file_setup_channels(), meter_print_buffer(), parse_channels(), print_status(), pru_data_setup(), pru_sample(), reset_config(), reset_offsets(), reset_scales(), rl_print_config(), and web_handle_data().
| #define NUM_DIGITAL_INPUTS 6 |
Number of RocketLogger digital channels.
Definition at line 110 of file types.h.
Referenced by file_handle_data(), file_setup_channels(), file_setup_lead_in(), pru_sample(), and web_handle_data().
| #define NUM_I_CHANNELS 2 |
Maximum number of RocketLogger current channels.
Definition at line 106 of file types.h.
Referenced by print_status(), rl_print_config(), and web_handle_data().
| #define NUM_SEMS 2 |
Number of semaphores in set.
Definition at line 314 of file types.h.
Referenced by main(), and pru_sample().
| #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 116 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 114 of file types.h.
Referenced by file_handle_data(), meter_print_buffer(), pru_data_setup(), pru_sample(), and web_handle_data().
| #define RL_CONF_VERSION 0x01 |
RocketLogger configuration structure version number.
Definition at line 206 of file types.h.
Referenced by read_default_config(), and reset_config().
| #define SEM_KEY 2222 |
Semaphore key (used for set creation)
Definition at line 312 of file types.h.
Referenced by main(), and pru_sample().
| #define SEM_SET_TIME_OUT 1 |
| #define SEM_TIME_OUT 3 |
Time out time in seconds, waiting on semaphore read.
Definition at line 316 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 318 of file types.h.
Referenced by web_handle_data().
| #define SHMEM_DATA_KEY 4443 |
Key for web shared memory (used for creation)
Definition at line 96 of file types.h.
Referenced by web_create_shm(), and web_open_shm().
| #define SHMEM_PERMISSIONS 0666 |
Permissions for shared memory.
Definition at line 98 of file types.h.
Referenced by read_status(), web_create_shm(), web_open_shm(), and write_status().
| #define SHMEM_STATUS_KEY 1111 |
Key for status shared memory (used for creation)
Definition at line 94 of file types.h.
Referenced by read_status(), and write_status().
| #define SUCCESS 1 |
Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Return code definitions
Definition at line 75 of file types.h.
Referenced by BME280_init(), BME280_read(), BME280_readCalibration(), BME280_setParameters(), 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(), pru_unmap_memory(), pwm_setup(), read_calibration(), read_default_config(), read_status(), remove_sem(), rl_start(), rl_stop(), Sensors_scan(), set_pid(), set_sem(), TSL4531_init(), TSL4531_read(), TSL4531_sendRange(), TSL4531_setParameters(), TSL4531_setRange(), wait_sem(), write_default_config(), and write_status().
| #define TIME_OUT 0 |
Definition at line 77 of file types.h.
Referenced by set_sem(), wait_sem(), and web_handle_data().
| #define UNDEFINED 0 |
Definition at line 76 of file types.h.
Referenced by read_default_config().
| #define V1_INDEX 2 |
Definition at line 231 of file types.h.
Referenced by web_merge_currents().
| #define V2_INDEX 3 |
Definition at line 232 of file types.h.
Referenced by web_merge_currents().
| #define V3_INDEX 6 |
Definition at line 235 of file types.h.
Referenced by web_merge_currents().
| #define V4_INDEX 7 |
Definition at line 236 of file types.h.
Referenced by web_merge_currents().
| #define WAIT_SEM 1 |
Number of wait semaphore in set (blocks all server processes, until new data is available)
Definition at line 326 of file types.h.
Referenced by main(), and pru_sample().
| typedef enum aggregation rl_aggregation |
RocketLogger data aggregation mode definition
| 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 aggregation |
| enum file_format |
| enum log_type |
| enum mode |
RocketLogger mode definition
| enum sampling |
| enum state |
| enum use_cal |
| struct rl_ambient ambient |
| struct rl_calibration calibration |
Calibration data.
Definition at line 335 of file types.h.
Referenced by file_handle_data(), meter_print_buffer(), read_calibration(), reset_offsets(), reset_scales(), rl_read_calibration(), and web_handle_data().
| const char* channel_names[NUM_CHANNELS] |
Channel names.
Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition at line 42 of file file_handling.c.
Referenced by file_setup_channels(), and meter_print_buffer().
| const char* digital_input_names[NUM_DIGITAL_INPUTS] |
Digital input names.
Definition at line 45 of file file_handling.c.
Referenced by file_setup_channels(), and meter_print_buffer().
| const char* valid_info_names[NUM_I_CHANNELS] |
Range valid information names.
Range valid information names.
Definition at line 48 of file file_handling.c.
Referenced by file_setup_channels().