Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Fix #426; Incorrect UUID for DS18B20 sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
savageautomate committed Feb 17, 2021
1 parent 7cf3290 commit bca68ef
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pi4j-core/src/main/java/com/pi4j/io/w1/W1BaseDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,11 @@ public W1BaseDevice(final File deviceDir) {
try {
deviceName = new String(Files.readAllBytes(new File(deviceDir, "name").toPath()));
} catch (IOException e) {
// FIXME logging
deviceName = deviceDir.getName();
}

// sanitize device name (remove any <LEADING> NULL, CR, LF, TAB, or SPACES)
while(deviceName.startsWith(" ") || // SPACE
deviceName.startsWith("\r") || // CR
deviceName.startsWith("\n") || // LF
deviceName.startsWith("\t") || // TAB
deviceName.startsWith("\0")) // NULL
deviceName = deviceName.substring(1);

// sanitize device name (remove any <TRAILING> NULL, CR, LF, TAB, or SPACES)
while(deviceName.endsWith(" ") || // SPACE
deviceName.endsWith("\r") || // CR
deviceName.endsWith("\n") || // LF
deviceName.endsWith("\t") || // TAB
deviceName.endsWith("\0")) // NULL
// sanitize device name (remove any leading or trailing spaces (CR,LF,NULL,TAB,etc))
deviceName = deviceName.trim();

// assign "name" and "id" attributes from device name
name = deviceName;
Expand Down

0 comments on commit bca68ef

Please sign in to comment.