1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| #include "sondes.h"
#include <fcntl.h>
#include <unistd.h>
#include <QDebug>
Sondes::Sondes()
{
qDebug() << "Sondes";
}
void Sondes::lireTemperatures()
{
if ((fd = open(path, O_RDONLY)) < 0) {
perror("Erreur ouverture de value de w1_slave");
exit(EXIT_FAILURE);
} else {
len = read(fd, buffer, sizeof(buffer));
strncpy(temp, buffer+len-6, 5);
tempExtLue = atof(temp)/1000;
//printf("TempExtLue = %2.3f C\n", tempExtLue);
}
if ((fd = open(path1, O_RDONLY)) < 0) {
perror("Erreur ouverture de value de w1_slave");
exit(EXIT_FAILURE);
} else {
len1 = read(fd, buffer, sizeof(buffer));
strncpy(temp1, buffer+len1-6, 5);
tempUnitExtLue = atof(temp1)/1000;
//printf("TempUnitExtLue = %2.3f C\n", tempUnitExtLue);
}
if ((fd = open(path2, O_RDONLY)) < 0) {
perror("Erreur ouverture de value de w1_slave");
exit(EXIT_FAILURE);
} else {
len2 = read(fd, buffer, sizeof(buffer));
strncpy(temp2, buffer+len2-6, 5);
tempEcExtLue = atof(temp2)/1000;
//printf("TempEcExtLue = %2.3f C\n", tempEcExtLue);
}
if ((fd = open(path3, O_RDONLY)) < 0) {
perror("Erreur ouverture de value de w1_slave");
exit(EXIT_FAILURE);
} else {
len3=read(fd, buffer, sizeof(buffer));
strncpy(temp3, buffer+len3-6, 5);
tempUnitIntLue=atof(temp3)/1000;
//printf("TempUnitIntLue = %2.3f C\n", tempUnitIntLue);
}
if ((fd = open(path4, O_RDONLY)) < 0) {
perror("Erreur ouverture de value de w1_slave");
exit(EXIT_FAILURE);
} else {
len4=read(fd, buffer, sizeof(buffer));
strncpy(temp4, buffer+len4-6, 5);
tempEcIntLue=atof(temp4)/1000;
//printf("TempEcIntLue = %2.3f C\n\n", tempEcIntLue);
}
close(fd);
sleep(5);
}
void Sondes::lectureConsigneIntCa()
{
consigneIntCa = tempExtLue - 6;
consigneVentIntCa = consigneIntCa + 2;
} |
Partager