org.openmuc.jmbus
public class MBusSap extends java.lang.Object
Constructor and Description |
---|
MBusSap(java.lang.String serialPort)
Creates an M-Bus Service Access Point that is used to read meters.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the serial port.
|
int |
getTimeout()
Returns the timeout in ms.
|
void |
open(int initialBaudRate)
Opens the serial port.
|
VariableDataResponse |
read(java.lang.String meterAddress)
Sends a data request (REQ_UD2) to the remote device and returns the Variable Data Response received.
|
void |
setTimeout(int timeout)
Sets the maximum time in ms to wait for new data from the remote device.
|
public MBusSap(java.lang.String serialPort)
serialPort
- examples for serial port identifiers are on Linux "/dev/ttyS0" or "/dev/ttyUSB0" and on Windows "COM1"public void setTimeout(int timeout)
timeout
- the maximum time in ms to wait for new data.public int getTimeout()
public void open(int initialBaudRate) throws java.io.IOException
initialBaudRate
- java.io.IOException
- if any kind of error occurs opening the serial port.public void close()
public VariableDataResponse read(java.lang.String meterAddress) throws java.io.IOException, java.util.concurrent.TimeoutException
meterAddress
- e.g. p1 or s...java.io.IOException
- if any kind of error (including timeout) occurs while trying to read the remote device. Note that the
connection is not closed when an IOException is thrown.java.util.concurrent.TimeoutException
- if no response at all (not even a single byte) was received from the meter within the timeout span.