Skip to content

Commit bc8a699

Browse files
committed
2 parents 79d2dce + 480eba6 commit bc8a699

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

hardware/1Wire/1WireByOWFS.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ float C1WireByOWFS::GetHumidity(const _t1WireDevice& device) const
228228

229229
float C1WireByOWFS::GetPressure(const _t1WireDevice& device) const
230230
{
231-
std::string readValue=readRawData(std::string(device.filename+"/pressure"));
231+
std::string realFilename = device.filename + nameHelper(device.filename, device.family); // for family 26 (DS2438) + pressure + HobbyBoards
232+
233+
std::string readValue=readRawData(std::string(realFilename+"/pressure"));
232234
if (readValue.empty())
233235
return -1000.0;
234236
return static_cast<float>(atof(readValue.c_str()));
@@ -412,14 +414,14 @@ void C1WireByOWFS::GetDevice(const std::string &inDir, const std::string &dirnam
412414
device.devid=id;
413415

414416
device.filename=inDir;
415-
if (device.family == Environmental_Monitors || device.family == smart_battery_monitor) {
416-
device.filename+="/" + dirname + nameHelper(dirname);;
417+
if (device.family == Environmental_Monitors) {
418+
device.filename+="/" + dirname + nameHelper(dirname, device.family);
417419
} else {
418420
device.filename+="/" + dirname;
419421
}
420422
}
421423

422-
std::string C1WireByOWFS::nameHelper(const std::string& dirname) const {
424+
std::string C1WireByOWFS::nameHelper(const std::string& dirname, const _e1WireFamilyType family) const {
423425
std::string name;
424426
DIR *d=NULL;
425427

@@ -432,7 +434,8 @@ std::string C1WireByOWFS::nameHelper(const std::string& dirname) const {
432434
name = de->d_name;
433435
if (de->d_type == DT_DIR)
434436
{
435-
if (name.compare(0, 3, "EDS") == 0 || name.compare(0, 7, "B1-R1-A") == 0) {
437+
if ( ((family == Environmental_Monitors) && (name.compare(0, 3, "EDS") == 0))
438+
|| ((family == smart_battery_monitor) && (name.compare(0, 7, "B1-R1-A") == 0)) ) {
436439
closedir(d);
437440
return "/" + name;
438441
}

hardware/1Wire/1WireByOWFS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ class C1WireByOWFS : public I_1WireSystem
4949
void GetDevices(const std::string &inDir, /*out*/std::vector<_t1WireDevice>& devices) const;
5050
std::string readRawData(const std::string& filename) const;
5151
void writeData(const _t1WireDevice& device,std::string propertyName,const std::string &value) const;
52-
std::string nameHelper(const std::string& dirname) const;
52+
std::string nameHelper(const std::string& dirname, const _e1WireFamilyType family) const;
5353
};

0 commit comments

Comments
 (0)