Skip to content

Commit

Permalink
Adjust error code values for disconnected sensor
Browse files Browse the repository at this point in the history
The existing values are within the operating range of the MAX31850.
  • Loading branch information
karlg100 committed Jan 2, 2021
1 parent 0d01352 commit ac1eb7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DallasTemperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
#define DS18S20MODEL 0x10 // also DS1820
#define DS18B20MODEL 0x28 // also MAX31820
#define DS1822MODEL 0x22
#define DS1825MODEL 0x3B
#define DS1825MODEL 0x3B // also MAX31850
#define DS28EA00MODEL 0x42

// Error Codes
#define DEVICE_DISCONNECTED_C -127
#define DEVICE_DISCONNECTED_F -196.6
#define DEVICE_DISCONNECTED_RAW -7040
#define DEVICE_DISCONNECTED_C -255

This comment has been minimized.

Copy link
@bobwolff68

bobwolff68 Jun 7, 2022

This change has created warnings in what was a totally clean build library. And it may also cause real problems in the disconnected case.
int8_t DallasTemperature::getHighAlarmTemp(const uint8_t* deviceAddress)
This function returns an 8-bit signed value who's range is -127 to 128 but the DEVICE_DISCONNECTED_C is now -255 (used to be -127). And so the compiler will convert the -255 to "1" which isn't the intended value and will fool some logic. Can this be fixed/updated?

This comment has been minimized.

Copy link
@RobTillaart

RobTillaart Jun 7, 2022

Contributor

After a quick look I confirm the possible problems. (no test setup run yet).
I assume there is quite some code out there that does check against -127 (hard coded) instead of the CONSTANT.

@bobwolff68
Can you create an issue for this?

Some thoughts

  1. revert the values and accept that they are in range of the MAX31850
  2. create a separate class for MAX31850
  3. create a derived class for MAX31850
  4. replace all int8_t code into int16_t in the library.
#define DEVICE_DISCONNECTED_F -427
#define DEVICE_DISCONNECTED_RAW -32640

// For readPowerSupply on oneWire bus
// definition of nullptr for C++ < 11, using official workaround:
Expand Down

2 comments on commit ac1eb7f

@milesburton
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume the quick fix here is to switch it back to -127? If so I change that quickly enough

@RobTillaart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milesburton that is indeed the quick fix.
more elaborate answer in the issue.

Please sign in to comment.