Bonjour,
dans mon application, il y a 2 octets pour la mesure de température : buf[13] et buf[14].
Lorsque la température est de 25,5°C, buf[13]=FF et buf[14]=00 (cela fonctionne bien), mais lorsque la température dépasse les 25,5°C, par exemple 30,7°C, cela fait buf[13]=33 et buf[14]=01 donc 0133 en héxa = 307 en décimal (30,7°C).
C'est bien cela mon problème, j'aimerai pouvoir traiter les températures supérieures à 25,5°C mais avec plusieurs tentatives, je n'y arrive toujours pas !
Si quelqu'un pouvait m'aider svp ?
Merci pour vos réponses, à bientôt !



Je poste mon code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
if ( buf[14] != 0)
{
unsigned char temp = ( buf[14]<<8 + buf [13]);
fprintf (fichier, "%.1f", (temp/10));
fprintf (fichier, " ");
//FormClient->FastLineSerieTemperature->AddXY( i, (float) (temp/10) , i, clRed);
}
else
{
fprintf (fichier, "%.1f", (float)buf[13]/10.0);
fprintf (fichier, " ");
FormClient->FastLineSerieTemperature->AddXY( i, ((float) buf [13]/10.0), i, clRed);
} |
Partager