13#include <netinet/in.h>
14#include <sys/socket.h>
16#define RECONNECTDELAY 3000
22 addr.sun_family = AF_UNIX;
40 if ((
f = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) {
41 if (connect(
f, (
struct sockaddr *)&
addr,
sizeof(
addr)) >= 0)
71 int ret = ready ?
safe_read(
f, buf,
sizeof(buf)) : -1;
73 if (
f < 0 || ready && ret <= 0) {
74 esyslog(
"ERROR: lircd connection broken, trying to reconnect every %.1f seconds",
float(
RECONNECTDELAY) / 1000);
81 isyslog(
"reconnected to lircd");
87 if (ready && ret > 0) {
91 if (sscanf(buf,
"%*x %x %29s", &count, KeyName) != 2) {
92 esyslog(
"ERROR: unparsable lirc command: %s", buf);
101 Put(LastKeyName,
false,
true);
102 strn0cpy(LastKeyName, KeyName,
sizeof(LastKeyName));
115 timeout = Delta * 3 / 2;
119 Put(KeyName, repeat);
123 if (pressed && repeat)
124 Put(LastKeyName,
false,
true);
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
static bool FileReady(int FileDes, int TimeoutMs=1000)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
cLircRemote(const char *DeviceName)
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
uint64_t Elapsed(void) const
void Set(int Ms=0)
Sets the timer.