Package org.harctoolbox.harchardware.ir
Class LircClient
java.lang.Object
org.harctoolbox.harchardware.ir.LircClient
- All Implemented Interfaces:
Closeable,AutoCloseable,IHarcHardware,IIrSenderStop,IRemoteCommandIrSender,ITransmitter
- Direct Known Subclasses:
LircCcfClient
public class LircClient
extends Object
implements IHarcHardware, IRemoteCommandIrSender, IIrSenderStop, ITransmitter
A LIRC client, talking to a remote LIRC
server through a TCP port.
Functionally, it resembles the command line program irsend.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final class -
Field Summary
FieldsFields inherited from interface org.harctoolbox.harchardware.ir.IRemoteCommandIrSender
repeatMax -
Constructor Summary
ConstructorsConstructorDescriptionLircClient(String hostname) LircClient(String hostname, Integer port, boolean verbose, Integer timeout) LircClient(InetAddress hostname) LircClient(InetAddress hostname, boolean verbose) LircClient(InetAddress hostname, boolean verbose, Integer timeout) LircClient(InetAddress hostname, Integer port, boolean verbose, Integer timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()String[]getCommands(String remote) Returns an array of command names for the remote given in the argument.String[]Returns an array of "remote" names.Returns a default Transmitter for the device.getTransmitter(int portNo) getTransmitter(String port) Parses the String argument, and returns a transmitter accordingly.String[]Return possible name of transmitters, that are guaranteed to work with the getTransmitter(String).Returns the hardware version (not the version of the driver software).booleanisValid()Dummy implementation, always returns truestatic voidvoidopen()Opens the device with previously set parameters.protected voidreadLoop()protected final String[]sendCommand(String packet, boolean oneWord) booleansendIrCommand(String remote, String command, int count, int connector) booleansendIrCommand(String remote, String command, int count, Transmitter transmitter) Sends the command to the hardware, to be sent count number of times.booleansendIrCommandRepeat(String remote, String command, Transmitter transmitter) Like sendIr, but sends the IR signal until stopped by stopIr.voidsetDebug(int debug) Sets a debug parameter.voidsetTimeout(int timeout) Set timeout in milliseconds.booleansetTransmitters(boolean[] ports) booleansetTransmitters(int port) booleansetTransmitters(Transmitter transmitter) Sends the SET_TRANSMITTER command to the LIRC server.voidsetVerbose(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.booleanbooleanstopIr(String remote, String command, Transmitter transmitter) booleanstopIr(Transmitter transmitter) Stops ongoing IR transmission.
-
Field Details
-
lircDefaultPort
public static final int lircDefaultPort- See Also:
-
defaultLircIP
- See Also:
-
defaultTimeout
public static final int defaultTimeout- See Also:
-
-
Constructor Details
-
LircClient
public LircClient(InetAddress hostname, Integer port, boolean verbose, Integer timeout) throws IOException - Throws:
IOException
-
LircClient
public LircClient(String hostname, Integer port, boolean verbose, Integer timeout) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
UnknownHostExceptionIOException
-
-
Method Details
-
main
- Parameters:
args- the command line arguments.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
open
public void open()Description copied from interface:IHarcHardwareOpens the device with previously set parameters.- Specified by:
openin interfaceIHarcHardware
-
getTransmitter
Description copied from interface:IRemoteCommandIrSenderReturns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.- Specified by:
getTransmitterin interfaceIRemoteCommandIrSender- Specified by:
getTransmitterin interfaceITransmitter- Returns:
- Transmitter
-
getTransmitter
- Throws:
NoSuchTransmitterException
-
getTransmitter
Description copied from interface:ITransmitterParses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitterin interfaceITransmitter- Parameters:
port- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
getTransmitterNames
Description copied from interface:ITransmitterReturn possible name of transmitters, that are guaranteed to work with the getTransmitter(String). This may be generated by inquiring the device, producing correct result, or it may be some static function, describing transmitters not necessarily present on the actually deployed device.- Specified by:
getTransmitterNamesin interfaceITransmitter- Returns:
- Array of strings that are guaranteed to work with the getTransmitter(String)
-
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
-
setDebug
public void setDebug(int debug) Description copied from interface:IHarcHardwareSets a debug parameter. Exact semantic depends on the implementation.- Specified by:
setDebugin interfaceIHarcHardware
-
setTimeout
public void setTimeout(int timeout) 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.
-
readLoop
- Throws:
IOException
-
sendCommand
- Throws:
IOException
-
sendIrCommand
public boolean sendIrCommand(String remote, String command, int count, Transmitter transmitter) throws IOException, NoSuchTransmitterException Description copied from interface:IRemoteCommandIrSenderSends the command to the hardware, to be sent count number of times.- Specified by:
sendIrCommandin interfaceIRemoteCommandIrSendercount- Number of times to repeat the command- Returns:
- success
- Throws:
IOExceptionNoSuchTransmitterException
-
sendIrCommand
public boolean sendIrCommand(String remote, String command, int count, int connector) throws IOException, NoSuchTransmitterException -
sendIrCommandRepeat
public boolean sendIrCommandRepeat(String remote, String command, Transmitter transmitter) throws IOException, NoSuchTransmitterException Description copied from interface:IRemoteCommandIrSenderLike sendIr, but sends the IR signal until stopped by stopIr. An implementation, or a hardware, may limit the number of repeats though.- Specified by:
sendIrCommandRepeatin interfaceIRemoteCommandIrSender- Returns:
- Throws:
IOExceptionNoSuchTransmitterException
-
stopIr
public boolean stopIr(String remote, String command, Transmitter transmitter) throws IOException, NoSuchTransmitterException -
stopIr
public boolean stopIr(String remote, String command, int port) throws IOException, NoSuchTransmitterException -
stopIr
Description copied from interface:IIrSenderStopStops ongoing IR transmission.- Specified by:
stopIrin interfaceIIrSenderStop- Returns:
- if false, command failed.
- Throws:
IOExceptionNoSuchTransmitterException
-
getRemotes
Description copied from interface:IRemoteCommandIrSenderReturns an array of "remote" names.- Specified by:
getRemotesin interfaceIRemoteCommandIrSender- Returns:
- Throws:
IOException
-
getCommands
Description copied from interface:IRemoteCommandIrSenderReturns an array of command names for the remote given in the argument.- Specified by:
getCommandsin interfaceIRemoteCommandIrSender- Parameters:
remote- The "remote" to search in- Returns:
- Throws:
IOException
-
setTransmitters
public boolean setTransmitters(Transmitter transmitter) throws NoSuchTransmitterException, IOException Sends the SET_TRANSMITTER command to the LIRC server.- Parameters:
transmitter-- Returns:
- Throws:
IOExceptionNoSuchTransmitterException
-
setTransmitters
-
setTransmitters
-
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
-
isValid
public boolean isValid()Dummy implementation, always returns true- Specified by:
isValidin interfaceIHarcHardware- Returns:
- true
-