main.c
parent
b0b3f2d021
commit
0b821ba02b
@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef DAQ_H
|
||||
#define DAQ_H
|
||||
|
||||
//HEADERS
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "uart.h"
|
||||
|
||||
//DEFINITIONS
|
||||
#define SprintIR 4 //co2 sensor
|
||||
#define COAF 1 //co sensor
|
||||
#define LOX_O2 2 //o2
|
||||
|
||||
//comands
|
||||
#define Rep_Dev_ID "Y\r\n"
|
||||
#define Pulling_Mode "K 2\r\n"
|
||||
#define OX_P_Mode "M 1\r\n"
|
||||
#define FILnUNFIL "M 6\r\n"
|
||||
#define unf_gas_con "z\r\n"
|
||||
#define fil_gas_con "Z\r\n"
|
||||
#define Temperature "T\r\n"
|
||||
#define get_readigns "Q\r\n"
|
||||
#define percent_oxigen "%\r\n"
|
||||
#define ppm_oxigen "O\r\n"
|
||||
#define M_zZTHBD "M 14406\r\n"
|
||||
#define M_zZTHB "M 12358\r\n"
|
||||
#define Readings_OX "A\r\n"
|
||||
|
||||
//FUNCTIONS
|
||||
int sensConf(unsigned char uartNumber, int baudRate, unsigned char mode[], unsigned char response[], int tries);
|
||||
int measure(unsigned char uartNumber, unsigned char command[], int multiplier, int excess);
|
||||
char *getMeasures(char src[], char fval, int nchar);
|
||||
int str2int(unsigned char *ptr);
|
||||
int DAQ(int t_hrs, int sp_s);
|
||||
|
||||
#endif
|
@ -0,0 +1,36 @@
|
||||
#include "daq.h"
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
int T_acq, t_samp;
|
||||
|
||||
if(argc!=3){
|
||||
printf("Invalid number of arguments,\n"\
|
||||
"Usage: daq <daq duration(h)> <sampling period(s)>\nexiting!\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
// configuring sensors
|
||||
printf("Configuring CO2 sensor\n");
|
||||
sensConf(SprintIR, B9600, Pulling_Mode, " K 00002\r\n", 5);
|
||||
sensConf(SprintIR, B9600, FILnUNFIL, " M 00006\r\n", 5);
|
||||
printf("Configuring CO sensor\n");
|
||||
sensConf(COAF, B9600, Pulling_Mode, "K 00002\r\n", 5);
|
||||
sensConf(COAF, B9600, M_zZTHB, "M 14406\r\n", 5);
|
||||
printf("Configuring O2 sensor\n");
|
||||
sensConf(LOX_O2, B9600, OX_P_Mode, "M 01\r\n", 5);
|
||||
|
||||
// acquiring
|
||||
T_acq = atoi(argv[1]);//str to int
|
||||
t_samp = atoi(argv[2]);
|
||||
printf("Starting data acquisition with duration of %dh every %ds\n", T_acq, t_samp);
|
||||
DAQ(T_acq, t_samp);
|
||||
|
||||
// deinit uart
|
||||
uartClose(SprintIR);
|
||||
uartClose(COAF);
|
||||
uartClose(LOX_O2);
|
||||
// finishing
|
||||
printf("Exiting of the program...\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue