File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -69,22 +69,20 @@ TEST(onewire_DS18x20, test_data_returned) {
69
69
}
70
70
71
71
// Verify that data was returned (non-zero values in the scratchpad)
72
- bool dataReturned = false ;
72
+ bool allDataNonZero = true ;
73
73
for (uint8_t i = 0 ; i < 9 ; i++) {
74
- if (data[i] ! = 0 ) {
75
- dataReturned = true ;
74
+ if (data[i] = = 0 ) {
75
+ allDataNonZero = false ;
76
76
break ;
77
77
}
78
- dataReturned = false ;
79
78
}
80
79
81
- TEST_ASSERT_TRUE_MESSAGE (dataReturned , " - No data returned from the OneWire device" );
80
+ TEST_ASSERT_TRUE_MESSAGE (allDataNonZero , " - Not all data bytes are non-zero in the OneWire device scratchpad " );
82
81
83
82
TEST_ASSERT_TRUE_MESSAGE (OneWire::crc8 (data, 8 ) == data[8 ], " - CRC check failed" );
84
83
85
84
// Decode temperature
86
85
int16_t raw = (data[1 ] << 8 ) | data[0 ];
87
- float celsius = (float )raw / 16.0 ;
88
86
if (addr[0 ] == 0x10 ) {
89
87
raw = raw << 3 ; // 9 bit resolution
90
88
if (data[7 ] == 0x10 ) {
@@ -98,6 +96,7 @@ TEST(onewire_DS18x20, test_data_returned) {
98
96
else if (cfg == 0x40 ) raw = raw & ~1 ; // 11 bit
99
97
}
100
98
99
+ float celsius = (float )raw / 16.0 ;
101
100
// Assert temperature is within expected range
102
101
TEST_ASSERT_TRUE_MESSAGE (
103
102
celsius > -50.0 && celsius < 50.0 ,
You can’t perform that action at this time.
0 commit comments