public interface IODevice
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(IODeviceEventListener listener)
Adds the specified listener to receive events from this device.
|
void |
ensureInitializationIsDone()
Waits for initialization is done.
|
I2CDevice |
getI2CDevice(byte address)
Returns I2C device by its address.
|
Pin |
getPin(int index)
Returns a pin by its index on device.
|
Set<Pin> |
getPins()
Returns a set of pins of the device.
|
int |
getPinsCount()
Returns count of pins of the device.
|
String |
getProtocol()
Returns the name of a protocol that the device uses.
|
boolean |
isReady()
Checks whether the device is fully initialized and ready to use.
|
void |
removeEventListener(IODeviceEventListener listener)
Removes the specified listener so that it no longer receives events from
this device.
|
void |
sendMessage(String message)
Sends arbitrary message to device.
|
void |
start()
Initiates communication with hardware.
|
void |
stop()
Terminates communication with hardware.
|
void start() throws IOException
IODevice
instance. Initialization may
take some time depending on speed of communication to hardware.isReady()
.ensureInitializationIsDone()
.IOException
- when communication cannot be establishedIODeviceEventListener.onStart(org.firmata4j.IOEvent)
void stop() throws IOException
IODeviceEventListener
s.IOException
- when communication cannot be properly terminatedIODeviceEventListener.onStop(org.firmata4j.IOEvent)
void ensureInitializationIsDone() throws InterruptedException
InterruptedException
- when the device cannot be started or waiting
for initialization is interrupted or connection has not been established
during timeout.boolean isReady()
Set<Pin> getPins()
Pin
int getPinsCount()
Pin getPin(int index)
getPinsCount()
.index
- index of the pinI2CDevice getI2CDevice(byte address) throws IOException
address
- IOException
- when communication to the IO device failedvoid addEventListener(IODeviceEventListener listener)
listener
- the listenervoid removeEventListener(IODeviceEventListener listener)
listener
- the listenerString getProtocol()
void sendMessage(String message) throws IOException
message
- the messageIOException
- when sending a message failsCopyright © 2017. All rights reserved.