diff --git a/daq b/daq index 6812fbc..39786ef 100755 Binary files a/daq and b/daq differ diff --git a/daq.c b/daq.c index 472072f..8f03b2b 100644 --- a/daq.c +++ b/daq.c @@ -9,7 +9,7 @@ #include #include"uart.c" -#define data_file_path "/var/lib/cloud9/c9projets/newUART/data.dat" +#define data_file_path "/var/lib/cloud9/daq-serial-bbb/data.dat" #define GC0017 4 //co2 #define CM31911 1 //co @@ -17,7 +17,7 @@ #define Rep_Dev_ID "Y\r\n" #define Pulling_Mode "K 2\r\n" -#define OX_P_Mode "K 1\r\n" +#define OX_P_Mode "M 1\r\n" #define unf_gas_con "z\r\n" #define fil_gas_con "Z\r\n" #define Temperature "T\r\n" @@ -33,24 +33,28 @@ int str2int(unsigned char *ptr); int DAQ(int t_hrs, int tm_s); -int main(int argc, int argT, int argt){ +int main(int argc, char *argv[]){ + + int T,t; if(argc!=3){ - printf("Invalid number of arguments,\n usage: daq \nexiting!\n"); - return -2; + printf("Invalid number of arguments,\n usage: daq \nexiting!\n"); + return -2; } + //configuración de sensores - printf("Configuring CO2 sensor\n"); - sensConf(GC0017, B9600, Pulling_Mode, " K 00002\r\n"); - printf("Configuring CO sensor\n"); - sensConf(CM31911, B9600, Pulling_Mode, "K 00002\r\n"); - //printf("Configuring O2 sensor\n"); - //sensConf(OX0052, B9600, OX_P_Mode, "??"); - + //printf("Configuring CO2 sensor\n"); + //sensConf(GC0017, B9600, Pulling_Mode, " K 00002\r\n"); + //printf("Configuring CO sensor\n"); + //sensConf(CM31911, B9600, Pulling_Mode, "K 00002\r\n"); + printf("Configuring O2 sensor\n"); + sensConf(OX0052, B9600, OX_P_Mode, "M 01\r\n"); //adquisición - printf("Starting data acquisition\n"); - DAQ(argT, argt); + T = atoi(argv[1]); + t = atoi(argv[2]); + printf("Starting data acquisition with duration of %dh and every %ds\n", T, t); + DAQ(T, t); sleep(1); //finalización @@ -138,8 +142,8 @@ int DAQ(int t_hrs, int tm_s) for(int i = 0; i < (t_hrs*3600); i=i+tm_s){ while((prev_time+tm_s) != (new_time = time(NULL))); start_t = clock(); - co2 = measure(GC0017, fil_gas_con, 10, 0); co = measure(CM31911, fil_gas_con, 1, 0); - /*o2 = measure(OX0052, percent_oxigen, 1, 0);*/temp = measure(CM31911, Temperature, 1, 1000); + //co2 = measure(GC0017, fil_gas_con, 10, 0); co = measure(CM31911, fil_gas_con, 1, 0); + o2 = measure(OX0052, percent_oxigen, 1, 0);///*temp = measure(CM31911, Temperature, 1, 1000); dfp = fopen(data_file_path, "a"); // open file for writing fprintf(dfp, "%ld \t\t%d\t\t%d\t\t%d\t\t%d\n", new_time-t0, co2, co, o2, temp); // send the value to the file fclose(dfp); // close the file using the file pointer