-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested with a fake modbus slave. Current code works.
Waiting on Bacharach MultiZone detector to come back to the shop for actual testing.
- Loading branch information
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/java/com/rbrubaker/multizone4j/TestModbusRead.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.rbrubaker.multizone4j; | ||
|
||
import com.ghgande.j2mod.modbus.ModbusException; | ||
|
||
public class TestModbusRead { | ||
|
||
public static void main(String[] args) throws IllegalArgumentException, ModbusException, Exception { | ||
// This object represents a Bacharach MultiZone device on the modbus serial network. | ||
// /dev/serial1 - This is the default RS485 port name on the Comfile PI | ||
MultiZoneDevice one = new MultiZoneDevice(1, "/dev/serial1"); | ||
|
||
// Read the current ppm and alarm status for zone 1. | ||
CurrentZoneStatus single = one.getCurrentZoneStatus(0); | ||
System.out.println(String.format("Single Read - Zone 1: %s ppm - %s alarm status", single.getPPM() + "", single.getAlarmStatus() + "")); | ||
|
||
int address = 1; | ||
for (CurrentZoneStatus status : one.getAllCurrentZoneStatuses()) { | ||
System.out.println(String.format("Zone %s: %s ppm - %s alarm status", address + "", status.getPPM() + "", status.getAlarmStatus() + "")); | ||
address++; | ||
} | ||
|
||
|
||
} | ||
|
||
} |