Package org.harctoolbox.harchardware.ir
Class IrSerial<T extends LocalSerialPort>
java.lang.Object
org.harctoolbox.harchardware.ir.IrSerial<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IHarcHardware
- Direct Known Subclasses:
CommandFusion
,IrGenericSerial
,IrToy
This class models a serial device that takes text commands from a serial port, like the Arduino.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionIrSerial
(Class<T> clazz, String portName, boolean verbose, Integer timeout, Integer baudRate, Integer dataSize, LocalSerialPort.StopBits stopBits, LocalSerialPort.Parity parity, LocalSerialPort.FlowControl flowControl) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Returns the hardware version (not the version of the driver software).boolean
isValid()
Checks validity of an instance.void
open()
Opens the device with previously set parameters.void
setBaudRate
(int baudRate) void
setDataSize
(int dataSize) void
setFlowControl
(LocalSerialPort.FlowControl flowControl) void
setParity
(LocalSerialPort.Parity parity) void
setPortName
(String portName) void
setStopBits
(LocalSerialPort.StopBits stopBits) void
setTimeout
(int timeout) Set timeout in milliseconds.void
setVerbose
(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.harctoolbox.harchardware.IHarcHardware
setDebug
-
Field Details
-
verbose
protected boolean verbose -
serialPort
-
-
Constructor Details
-
IrSerial
public IrSerial(Class<T> clazz, String portName, boolean verbose, Integer timeout, Integer baudRate, Integer dataSize, LocalSerialPort.StopBits stopBits, LocalSerialPort.Parity parity, LocalSerialPort.FlowControl flowControl) throws IOException - Throws:
IOException
-
-
Method Details
-
setBaudRate
public void setBaudRate(int baudRate) - Parameters:
baudRate
- the baudRate to set
-
setDataSize
public void setDataSize(int dataSize) - Parameters:
dataSize
- the dataSize to set
-
setStopBits
- Parameters:
stopBits
- the stopBits to set
-
setParity
- Parameters:
parity
- the parity to set
-
setFlowControl
- Parameters:
flowControl
- the flowControl to set
-
setPortName
- Parameters:
portName
- the portName to set
-
getVersion
Description copied from interface:IHarcHardware
Returns the hardware version (not the version of the driver software). May be null if no relevant information available.- Specified by:
getVersion
in interfaceIHarcHardware
- Returns:
- Version string. Semantics can vary.
- Throws:
IOException
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:IHarcHardware
Sets a verbosity flag, causing commands to be executed verbosely. Exact semantic depends on the implementation. Typically, all communication with the device is echoed to stderr.- Specified by:
setVerbose
in interfaceIHarcHardware
- Parameters:
verbose
- on or off
-
setTimeout
Description copied from interface:IHarcHardware
Set timeout in milliseconds. Exact semantics may be dependent on the hardware.- Specified by:
setTimeout
in interfaceIHarcHardware
- Parameters:
timeout
- Timeout in milliseconds.- Throws:
IOException
-
isValid
public boolean isValid()Description copied from interface:IHarcHardware
Checks validity of an instance. Exact meaning can vary.- Specified by:
isValid
in interfaceIHarcHardware
- Returns:
- validity of the instance.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getTransmitter
-
open
Description copied from interface:IHarcHardware
Opens the device with previously set parameters.- Specified by:
open
in interfaceIHarcHardware
- Throws:
HarcHardwareException
IOException
-