public class UsbGpioService extends java.lang.Object implements GpioService
GpioService.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_GPIO_COUNT
The
gpioCount property default value. |
static long |
DEFAULT_LISTEN_WAIT_MS
The
listenWaitMs property default value. |
| Constructor and Description |
|---|
UsbGpioService(net.solarnetwork.node.io.serial.SerialConnection conn)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configureIoDirection(java.util.BitSet set)
Configure the GPIO direction of all GPIO addresses.
|
void |
configureWriteMask(java.util.BitSet set)
Configure a bitmask to use on future
GpioService.configureIoDirection(BitSet) or GpioService.writeAll(BitSet) calls. |
java.lang.String |
getDeviceVersion()
Get the device version information.
|
int |
getGpioCount()
Get the GPIO count.
|
java.lang.String |
getId()
Get the ID of the device.
|
long |
getListenWaitMs()
Get the length of time to wait to read responses after writing a command,
in milliseconds.
|
boolean |
read(int address)
Get the value of the GPIO address as a binary value.
|
java.util.BitSet |
readAll()
Read the value of all GPIO addresses.
|
int |
readAnalog(int address)
Get the analog value of the GPIO address.
|
void |
set(int address,
boolean value)
Set the value of the GPIO address as a binary value.
|
void |
setGpioCount(int gpioCount)
Set the GPIO count.
|
void |
setId(java.lang.String id)
Set the ID of the device.
|
void |
setListenWaitMs(long listenWaitMs)
Set the length of time to wait to read responses after writing a command,
in milliseconds.
|
void |
writeAll(java.util.BitSet values)
Set the value of all GPIO addresses on enabled/disabled based on a
BitSet. |
public static final long DEFAULT_LISTEN_WAIT_MS
listenWaitMs property default value.public static final int DEFAULT_GPIO_COUNT
gpioCount property default value.public UsbGpioService(net.solarnetwork.node.io.serial.SerialConnection conn)
conn - the serial connection to usejava.lang.IllegalArgumentException - if any argument is nullpublic java.lang.String getDeviceVersion()
throws java.io.IOException
GpioServicegetDeviceVersion in interface GpioServicejava.io.IOException - if a communication error occurspublic java.lang.String getId()
throws java.io.IOException
GpioServicegetId in interface GpioServicejava.io.IOException - if a communication error occurspublic void setId(java.lang.String id)
throws java.io.IOException
GpioServicesetId in interface GpioServiceid - the ID to set: an 8-character stringjava.io.IOException - if a communication error occurspublic boolean read(int address)
throws java.io.IOException
GpioServiceread in interface GpioServiceaddress - the address, starting from 0, of the GPIO to getjava.io.IOException - if a communication error occurspublic void set(int address,
boolean value)
throws java.io.IOException
GpioServiceset in interface GpioServiceaddress - the address, starting from 0, of the GPIO to getvalue - true if the GPIO is on, otherwise falsejava.io.IOException - if a communication error occurspublic int readAnalog(int address)
throws java.io.IOException
GpioServicereadAnalog in interface GpioServiceaddress - the addressjava.io.IOException - if a communication error occurspublic java.util.BitSet readAll()
throws java.io.IOException
GpioServicereadAll in interface GpioServicejava.io.IOException - if a communication error occurspublic void writeAll(java.util.BitSet values)
throws java.io.IOException
GpioServiceBitSet.writeAll in interface GpioServicevalues - the value to set, with bit positions representing GPIO addressesjava.io.IOException - if a communication error occurspublic void configureWriteMask(java.util.BitSet set)
throws java.io.IOException
GpioServiceGpioService.configureIoDirection(BitSet) or GpioService.writeAll(BitSet) calls.configureWriteMask in interface GpioServiceset - the GPIO addresses to enable for future operations, using bit
positionsjava.io.IOException - if a communication error occurspublic void configureIoDirection(java.util.BitSet set)
throws java.io.IOException
GpioServiceIf a bit is enabled that means the coreponsing GPIO address should be configured as the input direction, otherwise as output.
configureIoDirection in interface GpioServiceset - the GPIO addresses to configure as input, using bit positionsjava.io.IOException - if a communication error occurspublic long getListenWaitMs()
DEFAULT_LISTEN_WAIT_MSpublic void setListenWaitMs(long listenWaitMs)
listenWaitMs - the milliseconds to set, or 0 to not wait at allpublic int getGpioCount()
DEFAULT_GPIO_COUNTpublic void setGpioCount(int gpioCount)
gpioCount - the gpioCount to setjava.lang.IllegalArgumentException - if gpioCount is less than 1