RocketLogger  1.1.4
types.h File Reference
#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...
 

Macro Definition Documentation

#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 AMBIENT_MAX_SENSOR_COUNT   128

Definition at line 209 of file types.h.

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

Calibration file name.

Definition at line 88 of file types.h.

Referenced by read_calibration().

#define CHANNEL_DISABLED   0

Channel sampling disabled.

Definition at line 221 of file types.h.

Referenced by hw_init().

#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 DIGIN1_BIT   2

Definition at line 126 of file types.h.

#define DIGIN2_BIT   4

Definition at line 127 of file types.h.

#define DIGIN3_BIT   8

Definition at line 128 of file types.h.

#define DIGIN4_BIT   2

Definition at line 129 of file types.h.

#define DIGIN5_BIT   4

Definition at line 130 of file types.h.

#define DIGIN6_BIT   8

Definition at line 131 of file types.h.

#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 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_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_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"

Log file name.

Definition at line 84 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 86 of file types.h.

Referenced by get_mac_addr().

#define MAX_LOG_FILE_SIZE   1000000

Log file size in bytes.

Definition at line 91 of file types.h.

Referenced by rl_log().

#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

Data update rate in METER mode.

Definition at line 112 of file types.h.

Referenced by rl_start().

#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

No flag.

Definition at line 329 of file types.h.

Referenced by set_sem(), and wait_sem().

#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

Maximum number of RocketLogger voltage channels.

Definition at line 108 of file types.h.

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

Process ID file for background process.

Definition at line 82 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 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

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

Definition at line 320 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 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-2018, 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:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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 Documentation

RocketLogger data aggregation mode definition

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 data aggregation mode definition

Enumerator
AGGREGATE_NONE 

No aggregation.

AGGREGATE_DOWNSAMPLE 

Aggregate using downsampling.

AGGREGATE_AVERAGE 

Aggregate by averaging data.

Definition at line 173 of file types.h.

RocketLogger file format definition

Enumerator
NO_FILE 

No file.

CSV 

CSV format.

BIN 

Binary format.

Definition at line 182 of file types.h.

enum log_type

RocketLogger log file types definition

Enumerator
ERROR 

Error.

WARNING 

Warning.

INFO 

Information.

Definition at line 199 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 157 of file types.h.

enum sampling

RocketLogger sampling state definition

Enumerator
SAMPLING_OFF 

Not sampling.

SAMPLING_ON 

Sampling.

Definition at line 149 of file types.h.

enum state

RocketLogger state definition

Enumerator
RL_OFF 

Idle.

RL_RUNNING 

Running.

RL_ERROR 

Error.

Definition at line 140 of file types.h.

enum use_cal

RocketLogger calibration definition

Enumerator
CAL_IGNORE 

Ignore calibration.

CAL_USE 

Use calibration (if existing)

Definition at line 191 of file types.h.

Variable Documentation

struct rl_ambient ambient
struct rl_calibration calibration
const char* channel_names[NUM_CHANNELS]

Channel names.

Copyright (c) 2016-2018, 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:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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().

struct rl_status status

RocketLogger status.

Definition at line 333 of file types.h.

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().