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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIrSerial(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 TypeMethodDescriptionvoidclose()Returns the hardware version (not the version of the driver software).booleanisValid()Checks validity of an instance.voidopen()Opens the device with previously set parameters.voidsetBaudRate(int baudRate) voidsetDataSize(int dataSize) voidsetFlowControl(LocalSerialPort.FlowControl flowControl) voidsetParity(LocalSerialPort.Parity parity) voidsetPortName(String portName) voidsetStopBits(LocalSerialPort.StopBits stopBits) voidsetTimeout(int timeout) Set timeout in milliseconds.voidsetVerbose(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, waitMethods 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:IHarcHardwareReturns the hardware version (not the version of the driver software). May be null if no relevant information available.- Specified by:
getVersionin interfaceIHarcHardware- Returns:
- Version string. Semantics can vary.
- Throws:
IOException
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:IHarcHardwareSets 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:
setVerbosein interfaceIHarcHardware- Parameters:
verbose- on or off
-
setTimeout
Description copied from interface:IHarcHardwareSet timeout in milliseconds. Exact semantics may be dependent on the hardware.- Specified by:
setTimeoutin interfaceIHarcHardware- Parameters:
timeout- Timeout in milliseconds.- Throws:
IOException
-
isValid
public boolean isValid()Description copied from interface:IHarcHardwareChecks validity of an instance. Exact meaning can vary.- Specified by:
isValidin interfaceIHarcHardware- Returns:
- validity of the instance.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getTransmitter
-
open
Description copied from interface:IHarcHardwareOpens the device with previously set parameters.- Specified by:
openin interfaceIHarcHardware- Throws:
HarcHardwareExceptionIOException
-