|
|
@ -51,13 +51,13 @@ int main(int argc, char *argv[]){
|
|
|
|
|
|
|
|
|
|
|
|
//configuración de sensores
|
|
|
|
//configuración de sensores
|
|
|
|
printf("Configuring CO2 sensor\n");
|
|
|
|
printf("Configuring CO2 sensor\n");
|
|
|
|
sensConf(GC0017, B9600, Pulling_Mode, " K 00002\r\n");
|
|
|
|
sensConf(GC0017, B9600, Pulling_Mode, " K 00002\r\n", 5);
|
|
|
|
sensConf(GC0017, B9600, FILnUNFIL, " M 00006\r\n");
|
|
|
|
sensConf(GC0017, B9600, FILnUNFIL, " M 00006\r\n", 5);
|
|
|
|
printf("Configuring CO sensor\n");
|
|
|
|
printf("Configuring CO sensor\n");
|
|
|
|
sensConf(CM31911, B9600, Pulling_Mode, "K 00002\r\n");
|
|
|
|
sensConf(CM31911, B9600, Pulling_Mode, "K 00002\r\n", 5);
|
|
|
|
sensConf(CM31911, B9600, M_zZTHBD, "M 14406\r\n");
|
|
|
|
sensConf(CM31911, B9600, M_zZTHBD, "M 14406\r\n", 5);
|
|
|
|
printf("Configuring O2 sensor\n");
|
|
|
|
printf("Configuring O2 sensor\n");
|
|
|
|
sensConf(OX0052, B9600, OX_P_Mode, "M 01\r\n");
|
|
|
|
sensConf(OX0052, B9600, OX_P_Mode, "M 01\r\n", 5);
|
|
|
|
|
|
|
|
|
|
|
|
//adquisición
|
|
|
|
//adquisición
|
|
|
|
T = atoi(argv[1]);//str to int
|
|
|
|
T = atoi(argv[1]);//str to int
|
|
|
@ -79,14 +79,13 @@ int main(int argc, char *argv[]){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sensConf(unsigned char uartNumber, int baudRate, unsigned char mode[], unsigned char response[]){
|
|
|
|
int sensConf(unsigned char uartNumber, int baudRate, unsigned char mode[], unsigned char response[], int tries){
|
|
|
|
|
|
|
|
|
|
|
|
int count;
|
|
|
|
int count;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uartConf(uartNumber, baudRate);
|
|
|
|
uartConf(uartNumber, baudRate);
|
|
|
|
|
|
|
|
|
|
|
|
while( i < 10 ){
|
|
|
|
while(tries){
|
|
|
|
uartTransmit(uartNumber, mode);
|
|
|
|
uartTransmit(uartNumber, mode);
|
|
|
|
tcdrain(uartFile[uartNumber]); //wait all data has been sent
|
|
|
|
tcdrain(uartFile[uartNumber]); //wait all data has been sent
|
|
|
|
printf("Command sended.\n");
|
|
|
|
printf("Command sended.\n");
|
|
|
@ -94,19 +93,19 @@ int sensConf(unsigned char uartNumber, int baudRate, unsigned char mode[], unsig
|
|
|
|
count = uartReceive(uartNumber);
|
|
|
|
count = uartReceive(uartNumber);
|
|
|
|
if (count == 0) printf("There was no data available to read!\n");
|
|
|
|
if (count == 0) printf("There was no data available to read!\n");
|
|
|
|
else if (strcmp(receive[uartNumber], response) == 0) {
|
|
|
|
else if (strcmp(receive[uartNumber], response) == 0) {
|
|
|
|
printf("Sensor configurated after %d tries.\n", i+1);
|
|
|
|
printf("Sensor configurated.\n");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
printf("The following was read in [%d]: %s\n",count,receive[uartNumber]);
|
|
|
|
printf("The following was read in [%d]: %s\n",count,receive[uartNumber]);
|
|
|
|
char *c = receive[uartNumber];
|
|
|
|
//char *c = receive[uartNumber];
|
|
|
|
while (*c != '\0'){
|
|
|
|
//while (*c != '\0'){
|
|
|
|
printf("%d = '%c'\n",*c, *c);
|
|
|
|
// printf("%d = '%c'\n",*c, *c);
|
|
|
|
c++;
|
|
|
|
// c++;
|
|
|
|
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tries --;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i ++;
|
|
|
|
printf("Sensor configuration failed.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("CO2 Sensor configuration failed.\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|