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

Commit

Permalink
Added serial.close() to examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
savageautomate committed Feb 17, 2021
1 parent 2570dce commit f760b36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pi4j-example/src/main/java/SerialBufferedDataExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ public static void main(String args[]) throws InterruptedException, IOException
System.out.println("[NO DATA AVAILABLE]");
}
}
catch(IllegalStateException ex){
catch(Exception ex){
ex.printStackTrace();
}
}

// we are done; close serial port
serial.close();
}
catch(IOException ex) {
console.println(" ==>> SERIAL SETUP FAILED : " + ex.getMessage());
Expand Down
2 changes: 2 additions & 0 deletions pi4j-example/src/main/java/SerialExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public void dataReceived(SerialDataEvent event) {
Thread.sleep(1000);
}

// we are done; close serial port
serial.close();
}
catch(IOException ex) {
console.println(" ==>> SERIAL SETUP FAILED : " + ex.getMessage());
Expand Down

0 comments on commit f760b36

Please sign in to comment.