Constructor and Description |
---|
FirmataDevice(String portName)
Constructs FirmataDevice instance on specified port.
|
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 |
serialEvent(jssc.SerialPortEvent event) |
void |
start()
Initiates communication with hardware.
|
void |
stop()
Terminates communication with hardware.
|
public FirmataDevice(String portName)
portName
- the port name the device is connected topublic void start() throws IOException
IODevice
IODevice
instance. Initialization may
take some time depending on speed of communication to hardware.IODevice.isReady()
.IODevice.ensureInitializationIsDone()
.start
in interface IODevice
IOException
- when communication cannot be establishedIODeviceEventListener.onStart(org.firmata4j.IOEvent)
public void stop() throws IOException
IODevice
IODeviceEventListener
s.stop
in interface IODevice
IOException
- when communication cannot be properly terminatedIODeviceEventListener.onStop(org.firmata4j.IOEvent)
public void ensureInitializationIsDone() throws InterruptedException
IODevice
ensureInitializationIsDone
in interface IODevice
InterruptedException
- when the device cannot be started or waiting
for initialization is interrupted or connection has not been established
during timeout.public boolean isReady()
IODevice
public void addEventListener(IODeviceEventListener listener)
IODevice
addEventListener
in interface IODevice
listener
- the listenerpublic void removeEventListener(IODeviceEventListener listener)
IODevice
removeEventListener
in interface IODevice
listener
- the listenerpublic Set<Pin> getPins()
IODevice
public int getPinsCount()
IODevice
getPinsCount
in interface IODevice
public Pin getPin(int index)
IODevice
IODevice.getPinsCount()
.public I2CDevice getI2CDevice(byte address) throws IOException
IODevice
getI2CDevice
in interface IODevice
IOException
- when communication to the IO device failedpublic String getProtocol()
IODevice
getProtocol
in interface IODevice
public void sendMessage(String message) throws IOException
IODevice
sendMessage
in interface IODevice
message
- the messageIOException
- when sending a message failspublic void serialEvent(jssc.SerialPortEvent event)
serialEvent
in interface jssc.SerialPortEventListener
Copyright © 2017. All rights reserved.