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
Modifier and TypeClassDescriptionstatic final class
static final class
static final class
static final class
static final class
static final class
static final class
-
Field Summary
Fields inherited from interface org.harctoolbox.harchardware.ir.IRemoteCommandIrSender
repeatMax
-
Constructor Summary
ConstructorDescriptionLircClient
(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 TypeMethodDescriptionvoid
close()
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).boolean
isValid()
Dummy implementation, always returns truestatic void
void
open()
Opens the device with previously set parameters.protected void
readLoop()
protected final String[]
sendCommand
(String packet, boolean oneWord) boolean
sendIrCommand
(String remote, String command, int count, int connector) boolean
sendIrCommand
(String remote, String command, int count, Transmitter transmitter) Sends the command to the hardware, to be sent count number of times.boolean
sendIrCommandRepeat
(String remote, String command, Transmitter transmitter) Like sendIr, but sends the IR signal until stopped by stopIr.void
setDebug
(int debug) Sets a debug parameter.void
setTimeout
(int timeout) Set timeout in milliseconds.boolean
setTransmitters
(boolean[] ports) boolean
setTransmitters
(int port) boolean
setTransmitters
(Transmitter transmitter) Sends the SET_TRANSMITTER command to the LIRC server.void
setVerbose
(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.boolean
boolean
stopIr
(String remote, String command, Transmitter transmitter) boolean
stopIr
(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:
UnknownHostException
IOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
IOException
-
LircClient
- Throws:
UnknownHostException
IOException
-
-
Method Details
-
main
- Parameters:
args
- the command line arguments.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
open
public void open()Description copied from interface:IHarcHardware
Opens the device with previously set parameters.- Specified by:
open
in interfaceIHarcHardware
-
getTransmitter
Description copied from interface:IRemoteCommandIrSender
Returns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.- Specified by:
getTransmitter
in interfaceIRemoteCommandIrSender
- Specified by:
getTransmitter
in interfaceITransmitter
- Returns:
- Transmitter
-
getTransmitter
- Throws:
NoSuchTransmitterException
-
getTransmitter
Description copied from interface:ITransmitter
Parses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitter
in interfaceITransmitter
- Parameters:
port
- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
getTransmitterNames
Description copied from interface:ITransmitter
Return 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:
getTransmitterNames
in interfaceITransmitter
- Returns:
- Array of strings that are guaranteed to work with the getTransmitter(String)
-
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
-
setDebug
public void setDebug(int debug) Description copied from interface:IHarcHardware
Sets a debug parameter. Exact semantic depends on the implementation.- Specified by:
setDebug
in interfaceIHarcHardware
-
setTimeout
public void setTimeout(int timeout) 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.
-
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:IRemoteCommandIrSender
Sends the command to the hardware, to be sent count number of times.- Specified by:
sendIrCommand
in interfaceIRemoteCommandIrSender
count
- Number of times to repeat the command- Returns:
- success
- Throws:
IOException
NoSuchTransmitterException
-
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:IRemoteCommandIrSender
Like sendIr, but sends the IR signal until stopped by stopIr. An implementation, or a hardware, may limit the number of repeats though.- Specified by:
sendIrCommandRepeat
in interfaceIRemoteCommandIrSender
- Returns:
- Throws:
IOException
NoSuchTransmitterException
-
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:IIrSenderStop
Stops ongoing IR transmission.- Specified by:
stopIr
in interfaceIIrSenderStop
- Returns:
- if false, command failed.
- Throws:
IOException
NoSuchTransmitterException
-
getRemotes
Description copied from interface:IRemoteCommandIrSender
Returns an array of "remote" names.- Specified by:
getRemotes
in interfaceIRemoteCommandIrSender
- Returns:
- Throws:
IOException
-
getCommands
Description copied from interface:IRemoteCommandIrSender
Returns an array of command names for the remote given in the argument.- Specified by:
getCommands
in 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:
IOException
NoSuchTransmitterException
-
setTransmitters
-
setTransmitters
-
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
-
isValid
public boolean isValid()Dummy implementation, always returns true- Specified by:
isValid
in interfaceIHarcHardware
- Returns:
- true
-