RocketLogger  1.0
types.h
Go to the documentation of this file.
1 
5 #ifndef RL_TYPES_H
6 #define RL_TYPES_H
7 
8 // INCLUDES
9 
10 // standard
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <stdint.h>
15 #include <unistd.h>
16 #include <stdarg.h>
17 #include <errno.h>
18 #include <ctype.h>
19 
20 // ipc, memory mapping, multithreading
21 #include <signal.h>
22 #include <sys/shm.h>
23 #include <sys/mman.h>
24 #include <pthread.h>
25 
26 // files
27 #include <fcntl.h>
28 #include <poll.h>
29 #include <sys/stat.h>
30 
31 // time
32 #include <time.h>
33 #include <sys/time.h>
34 
35 // pru
36 #include <prussdrv.h>
37 #include <pruss_intc_mapping.h>
38 
39 // ncurses (text-based UI)
40 #include <ncurses.h>
41 
42 
43 
44 // DEFINES
45 
46 // return codes
50 #define SUCCESS 1
51 #define UNDEFINED 0
52 #define TIME_OUT 0
53 #define FAILURE -1
54 
55 // files
57 #define PID_FILE "/var/run/rocketlogger.pid"
58 #define LOG_FILE "/var/www/log/log.txt"
60 #define MAC_ADDRESS_FILE "/sys/class/net/eth0/address"
62 #define CALIBRATION_FILE "/etc/rocketlogger/calibration.dat"
64 
66 #define MAX_LOG_FILE_SIZE 1000000
67 
69 #define SHMEM_STATUS_KEY 1111
70 #define SHMEM_DATA_KEY 4443
72 
73 
74 // constants
76 #define MAX_PATH_LENGTH 100
77 #define NUM_CHANNELS 8
79 #define NUM_I_CHANNELS 2
81 #define NUM_V_CHANNELS 4
83 #define NUM_DIGITAL_INPUTS 6
85 #define METER_UPDATE_RATE 5
87 #define PRU_DIG_SIZE 2
89 #define PRU_BUFFER_STATUS_SIZE 4
91 
93 #define KSPS 1000
94 
98 #define I1L_VALID_BIT 1
99 #define I2L_VALID_BIT 1
100 #define DIGIN1_BIT 2
101 #define DIGIN2_BIT 4
102 #define DIGIN3_BIT 8
103 #define DIGIN4_BIT 2
104 #define DIGIN5_BIT 4
105 #define DIGIN6_BIT 8
106 
108 #define MIN_ADC_RATE 1000
109 
110 
111 
112 // ROCKETLOGGER
116 typedef enum state {
117  RL_OFF = 0,
119  RL_ERROR = -1
120 } rl_state;
121 
125 typedef enum sampling {
128 } rl_sampling;
129 
133 typedef enum mode {
144 } rl_mode;
145 
149 typedef enum file_format {
150  NO_FILE = 0,
151  CSV = 1,
152  BIN = 2
154 
158 typedef enum use_cal {
160  CAL_USE = 1
161 } rl_use_cal;
162 
166 typedef enum log_type {
170 } rl_log_type;
171 
172 
173 
174 // channel properties
176 #define CHANNEL_DISABLED 0
177 #define CHANNEL_ENABLED 1
179 
180 // channel indices in channels array
184 #define I1H_INDEX 0
185 #define I1L_INDEX 1
186 #define V1_INDEX 2
187 #define V2_INDEX 3
188 #define I2H_INDEX 4
189 #define I2L_INDEX 5
190 #define V3_INDEX 6
191 #define V4_INDEX 7
192 
193 // digital inputs
195 #define DIGITAL_INPUTS_DISABLED 0
196 #define DIGITAL_INPUTS_ENABLED 1
198 
202 struct rl_conf {
224  uint64_t max_file_size;
227 };
228 
232 struct rl_status {
238  uint64_t samples_taken;
240  uint32_t buffer_number;
242  struct rl_conf conf;
245 };
246 
252  uint64_t time;
254  int offsets[NUM_CHANNELS];
256  double scales[NUM_CHANNELS];
257 };
258 
259 
260 // SEMAPHORES
262 #define SEM_KEY 2222
263 #define NUM_SEMS 2
265 #define SEM_TIME_OUT 3
267 #define SEM_WRITE_TIME_OUT 1
269 #define SEM_SET_TIME_OUT 1
271 
273 #define DATA_SEM 0
274 #define WAIT_SEM 1
276 
278 #define NO_FLAG 0
279 
280 // ----- GLOBAL VARIABLES ----- //
286 extern const char* channel_names[NUM_CHANNELS];
288 extern const char* digital_input_names[NUM_DIGITAL_INPUTS];
290 extern const char* valid_info_names[NUM_I_CHANNELS];
291 
292 #endif
int force_high_channels[NUM_I_CHANNELS]
Current channels to force to high range.
Definition: types.h:214
Limited sampling mode (limited by number of samples to take)
Definition: types.h:134
Print default configuration.
Definition: types.h:140
Get current status of RocketLogger.
Definition: types.h:137
#define NUM_DIGITAL_INPUTS
Number of RocketLogger digital channels.
Definition: types.h:84
rl_mode mode
Sampling mode.
Definition: types.h:204
Stop continuous sampling.
Definition: types.h:138
Continuous sampling mode (in background)
Definition: types.h:135
CSV format.
Definition: types.h:151
sampling
Definition: types.h:125
mode
Definition: types.h:133
enum mode rl_mode
int digital_inputs
En-/disable digital inputs.
Definition: types.h:216
#define MAX_PATH_LENGTH
Maximum path length in characters.
Definition: types.h:76
use_cal
Definition: types.h:158
int enable_web_server
En-/disable plots on web interface.
Definition: types.h:218
rl_use_cal calibration
Use/ignore existing calibration.
Definition: types.h:220
Binary format.
Definition: types.h:152
Show help.
Definition: types.h:142
const char * valid_info_names[NUM_I_CHANNELS]
Range valid information names.
Definition: file_handling.c:12
rl_state state
State.
Definition: types.h:234
uint64_t samples_taken
Number of samples taken.
Definition: types.h:238
state
Definition: types.h:116
#define NUM_I_CHANNELS
Maximum number of RocketLogger current channels.
Definition: types.h:80
log_type
Definition: types.h:166
int sample_limit
Sample limit (0 for continuous)
Definition: types.h:210
Definition: types.h:202
enum sampling rl_sampling
#define NUM_CHANNELS
Maximum number of RocketLogger channels.
Definition: types.h:78
enum use_cal rl_use_cal
Warning.
Definition: types.h:168
char file_name[MAX_PATH_LENGTH]
Data file name.
Definition: types.h:226
Running.
Definition: types.h:118
Set default configuration.
Definition: types.h:139
int channels[NUM_CHANNELS]
Channels to sample.
Definition: types.h:212
enum log_type rl_log_type
uint64_t time
Time stamp of calibration run.
Definition: types.h:252
Print the RocketLogger Software Stack version.
Definition: types.h:141
uint64_t calibration_time
Time stamp of last calibration run.
Definition: types.h:244
enum file_format rl_file_format
rl_file_format file_format
File format.
Definition: types.h:222
uint32_t buffer_number
Number of buffers taken.
Definition: types.h:240
int update_rate
Data update rate.
Definition: types.h:208
Error.
Definition: types.h:167
int sample_rate
Sampling rate.
Definition: types.h:206
No file.
Definition: types.h:150
const char * channel_names[NUM_CHANNELS]
Channel names.
Definition: file_handling.c:8
Not sampling.
Definition: types.h:126
struct rl_status status
RocketLogger status.
Definition: types.h:282
Use calibration (if existing)
Definition: types.h:160
uint64_t max_file_size
Maximum data file size.
Definition: types.h:224
Sampling.
Definition: types.h:127
rl_sampling sampling
Sampling state.
Definition: types.h:236
Ignore calibration.
Definition: types.h:159
Information.
Definition: types.h:169
Meter mode (display current values in terminal)
Definition: types.h:136
Error.
Definition: types.h:119
enum state rl_state
const char * digital_input_names[NUM_DIGITAL_INPUTS]
Digital input names.
Definition: file_handling.c:10
No mode.
Definition: types.h:143
Idle.
Definition: types.h:117
file_format
Definition: types.h:149