int mp_input_lirc_init(void) { int lirc_sock; int mode; mp_tmsg(MSGT_LIRC,MSGL_V,"Setting up LIRC support...\n"); if((lirc_sock=lirc_init("mpv",0))==-1){ mp_tmsg(MSGT_LIRC,MSGL_V,"Failed to open LIRC support. You will not be able to use your remote control.\n"); return -1; } mode = fcntl(lirc_sock, F_GETFL); if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) { mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n", strerror(errno)); lirc_deinit(); return -1; } if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){ mp_tmsg(MSGT_LIRC,MSGL_ERR,"Failed to read LIRC config file %s.\n", lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); lirc_deinit(); return -1; } return lirc_sock; }
void layout_image_lirc_init(LayoutWindow *lw) { gint flags; gboolean lirc_verbose = (get_debug_level() >= 2); lirc_fd = lirc_init(GQ_APPNAME_LC, lirc_verbose); if (lirc_fd == -1) { DEBUG_1("Initializing LIRC... failed"); return; } DEBUG_1("Initializing LIRC... OK"); if (lirc_readconfig(NULL, &config, NULL) == -1) { lirc_deinit(); g_fprintf(stderr, _("could not read LIRC config file\n" "please read the documentation of LIRC to \n" "know how to create a proper config file\n")); fflush(stderr); DEBUG_1("Failed to read LIRC config file"); return; } if (lirc_verbose) fflush(stderr); gio_chan = g_io_channel_unix_new(lirc_fd); input_tag = g_io_add_watch(gio_chan, G_IO_IN, lirc_input_callback, lw); fcntl(lirc_fd, F_SETOWN, getpid()); flags = fcntl(lirc_fd, F_GETFL, 0); if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK); }
int LircClient::Init(const QString &config_file, const QString &program, bool ignoreExtApp) { int fd; /* Connect the unix socket */ fd = lirc_init((char *)program.latin1(), 1); if (fd == -1) { VERBOSE(VB_IMPORTANT, QString("lirc_init failed for %1, see preceding messages") .arg(program)); return -1; } /* parse the config file */ if (lirc_readconfig((char *)config_file.latin1(), &lircConfig, NULL)) { VERBOSE(VB_IMPORTANT, QString("Failed to read lirc config %1 for %2") .arg(config_file).arg(program)); lirc_deinit(); return -1; } if (!ignoreExtApp) external_app = gContext->GetSetting("LircKeyPressedApp", ""); VERBOSE(VB_GENERAL, QString("lirc init success using configuration file: %1") .arg(config_file)); return 0; }
int mp_input_lirc_init(void) { int lirc_sock; int mode; mp_msg(MSGT_LIRC, MSGL_V, "Setting up LIRC support...\n"); if((lirc_sock=lirc_init("mplayer",1))==-1){ mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed); return -1; } mode = fcntl(lirc_sock, F_GETFL); if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) { mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n", strerror(errno)); lirc_deinit(); return -1; } if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){ mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr, lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); lirc_deinit(); return -1; } return lirc_sock; }
void init_lirc (void) { int flags; if ((lirc_fd = lirc_init ("audacious", 1)) == -1) { fprintf (stderr, _("%s: could not init LIRC support\n"), plugin_name); return; } if (lirc_readconfig (NULL, &config, NULL) == -1) { lirc_deinit (); fprintf (stderr, _("%s: could not read LIRC config file\n" "%s: please read the documentation of LIRC\n" "%s: how to create a proper config file\n"), plugin_name, plugin_name, plugin_name); return; } input_tag = g_io_add_watch (g_io_channel_unix_new (lirc_fd), G_IO_IN, lirc_input_callback, NULL); fcntl (lirc_fd, F_SETOWN, getpid ()); flags = fcntl (lirc_fd, F_GETFL, 0); if (flags != -1) { fcntl (lirc_fd, F_SETFL, flags | O_NONBLOCK); } fflush (stdout); }
int main (int argc, const char *argv[]) { int fd; struct lirc_config *config; char *code; if ((fd = lirc_init("lirc", 1)) == -1) { fprintf(stderr, "cannot init lirc\n"); exit(EXIT_FAILURE); } fprintf(stdout, "LIRC FD = %d\n", fd); fflush(stdout); #if 0 // XXX test non-block socket (for integration with tcdr) if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK) == -1) { fprintf(stderr, "cannot make socket as non block\n"); exit(EXIT_FAILURE); } #endif if (lirc_readconfig(NULL, &config, NULL) == 0) { while (lirc_nextcode(&code) == 0) { if (!code) continue; if (strstr(code, "KEY_MENU")) { fprintf(stdout, "MENU\n"); fflush(stdout); } else if (strstr(code, "KEY_PLAYPAUSE")) { fprintf(stdout, "PLAY\n"); fflush(stdout); } else if (strstr(code, "KEY_FORWARD")) { fprintf(stdout, "FWRD\n"); fflush(stdout); } else if (strstr(code, "KEY_REWIND")) { fprintf(stdout, "RWND\n"); fflush(stdout); } else if (strstr(code, "KEY_VOLUMEUP")) { fprintf(stdout, "VLUP\n"); fflush(stdout); } else if (strstr(code, "KEY_VOLUMEDOWN")) { fprintf(stdout, "VLDN\n"); fflush(stdout); } else { fprintf(stderr, "UNKN\n"); } free(code); } lirc_freeconfig(config); } lirc_deinit(); return 0; }
int pa__init(pa_module*m) { pa_modargs *ma = NULL; struct userdata *u; pa_volume_t volume_limit = PA_CLAMP_VOLUME(PA_VOLUME_NORM*3/2); pa_volume_t volume_step = PA_VOLUME_NORM/20; pa_assert(m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("Failed to parse module arguments"); goto fail; } if (pa_modargs_get_value_u32(ma, "volume_limit", &volume_limit) < 0) { pa_log("Failed to parse volume limit"); goto fail; } if (pa_modargs_get_value_u32(ma, "volume_step", &volume_step) < 0) { pa_log("Failed to parse volume step"); goto fail; } m->userdata = u = pa_xnew(struct userdata, 1); u->module = m; u->io = NULL; u->config = NULL; u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); u->lirc_fd = -1; u->mute_toggle_save = 0; u->volume_limit = PA_CLAMP_VOLUME(volume_limit); u->volume_step = PA_CLAMP_VOLUME(volume_step); if ((u->lirc_fd = lirc_init((char*) pa_modargs_get_value(ma, "appname", "pulseaudio"), 1)) < 0) { pa_log("lirc_init() failed."); goto fail; } if (lirc_readconfig((char*) pa_modargs_get_value(ma, "config", NULL), &u->config, NULL) < 0) { pa_log("lirc_readconfig() failed."); goto fail; } u->io = m->core->mainloop->io_new(m->core->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u); pa_modargs_free(ma); return 0; fail: if (ma) pa_modargs_free(ma); pa__done(m); return -1; }
void lircclient::init() { if (!_initialized) { int socket_flags; _socket = lirc_init(const_cast<char *>(_client_name.c_str()), msg::level() == msg::DBG ? 1 : 0); if (_socket == -1) { throw exc(_("Cannot initialize LIRC.")); } if ((socket_flags = fcntl(_socket, F_GETFL)) < 0 || fcntl(_socket, F_SETFL, socket_flags | O_NONBLOCK) < 0) { lirc_deinit(); throw exc(_("Cannot set LIRC socket properties.")); } if (_conf_files.size() == 0) { if (lirc_readconfig(NULL, &_config, NULL) != 0) { lirc_deinit(); throw exc(_("Cannot read LIRC default configuration.")); } } else { _config = NULL; for (size_t i = 0; i < _conf_files.size(); i++) { if (lirc_readconfig(const_cast<char *>(_conf_files[i].c_str()), &_config, NULL) != 0) { if (_config) { lirc_freeconfig(_config); } lirc_deinit(); throw exc(str::asprintf(_("Cannot read LIRC configuration file %s."), _conf_files[i].c_str())); } } } _initialized = true; } }
static void impl_activate (PeasActivatable *bplugin) { int fd; char *path; RBLircPlugin *plugin = RB_LIRC_PLUGIN (bplugin); RBShell *shell; g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "shell-player", &plugin->shell_player, NULL); rb_debug ("Activating lirc plugin"); fd = lirc_init ("Rhythmbox", 1); if (fd < 0) { rb_debug ("Couldn't initialize lirc"); g_object_unref (shell); return; } /* Load the default Rhythmbox setup */ path = rb_find_plugin_data_file (G_OBJECT (plugin), "rhythmbox_lirc_default"); if (path == NULL || lirc_readconfig (path, &plugin->lirc_config, NULL) == -1) { g_free (path); close (fd); rb_debug ("Couldn't read lirc configuration"); g_object_unref (shell); return; } g_free (path); lirc_readconfig (NULL, &plugin->lirc_config, NULL); plugin->lirc_channel = g_io_channel_unix_new (fd); g_io_channel_set_encoding (plugin->lirc_channel, NULL, NULL); g_io_channel_set_buffered (plugin->lirc_channel, FALSE); g_io_add_watch (plugin->lirc_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc) rb_lirc_plugin_read_code, plugin); g_object_unref (shell); }
static gboolean impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error) { TotemLircPlugin *pi = TOTEM_LIRC_PLUGIN (plugin); char *path; int fd; pi->totem = g_object_ref (totem); fd = lirc_init ("Totem", 0); if (fd < 0) { g_set_error_literal (error, TOTEM_PLUGIN_ERROR, TOTEM_PLUGIN_ERROR_ACTIVATION, _("Couldn't initialize lirc.")); return FALSE; } /* Load the default Totem setup */ path = totem_plugin_find_file (plugin, "totem_lirc_default"); if (path == NULL || lirc_readconfig (path, &pi->lirc_config, NULL) == -1) { g_free (path); g_set_error_literal (error, TOTEM_PLUGIN_ERROR, TOTEM_PLUGIN_ERROR_ACTIVATION, _("Couldn't read lirc configuration.")); close (fd); return FALSE; } g_free (path); /* Load the user config, doesn't matter if it's not there */ lirc_readconfig (NULL, &pi->lirc_config, NULL); pi->lirc_channel = g_io_channel_unix_new (fd); g_io_channel_set_encoding (pi->lirc_channel, NULL, NULL); g_io_channel_set_buffered (pi->lirc_channel, FALSE); g_io_add_watch (pi->lirc_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc) totem_lirc_read_code, pi); return TRUE; }
void lircStart(void) { if((g_lircfd = lirc_init("mupen64plus", 1)) != -1) { g_config = NULL; if(lirc_readconfig(NULL, &g_config, NULL) == 0) DebugMessage(M64MSG_INFO, "LIRC input system started successfully"); else DebugMessage(M64MSG_WARNING, "LIRC disabled: Error reading lircrc!"); } else DebugMessage(M64MSG_WARNING, "LIRC disabled: Error contacting daemon!"); }
static void *thread_func(void *arg) { struct lirc_config *config; int sock, flags; if ((sock = lirc_init("gmu", 1)) != -1) { fcntl(sock, F_SETOWN, getpid()); flags = fcntl(sock, F_GETFL, 0); if (flags != -1) fcntl(sock, F_SETFL, flags|O_NONBLOCK); if (lirc_readconfig(NULL, &config, NULL) == 0) { char *code, *c; int ret = 0; while (run && lirc_nextcode(&code) == 0) { if (code != NULL) { if ((ret = lirc_code2char(config, code, &c)) == 0 && c != NULL) { wdprintf(V_DEBUG, "lirc_frontend", "Got button press.\n"); if (strcmp(c, "play") == 0) gmu_core_play(); else if (strcmp(c, "pause") == 0) gmu_core_pause(); else if (strcmp(c, "stop") == 0) gmu_core_stop(); else if (strcmp(c, "toggle_pause") == 0) gmu_core_play_pause(); else if (strcmp(c, "toggle_play_pause") == 0) gmu_core_play_pause(); else if (strcmp(c, "next") == 0) gmu_core_next(); else if (strcmp(c, "prev") == 0) gmu_core_previous(); else if (strcmp(c, "volume_up") == 0) gmu_core_set_volume(gmu_core_get_volume()+1); else if (strcmp(c, "volume_down") == 0) gmu_core_set_volume(gmu_core_get_volume()-1); else wdprintf(V_WARNING, "lirc_frontend", "Unknown command: %s\n", c); c = NULL; } } usleep(400); free(code); if (ret == -1) break; } wdprintf(V_INFO, "lirc_frontend", "Exitting.\n"); lirc_freeconfig(config); } lirc_deinit(); } return NULL; }
/* Try to open a connection to lircd if suppor is enabled ** if it fails, disable support, print a message and continue */ void init_lirc(void) { if (using_lirc) { using_lirc = false; if ((lirc_fd = lirc_init("squeezeslave",1)) > 0) { if (lirc_readconfig(lircrc, &lircconfig, NULL)==0) { using_lirc = true; setNonblocking(lcd_fd); } else { using_lirc = true; close_lirc(); } } if (!using_lirc ) fprintf(stderr, "Failed to init LIRC\n"); } }
static struct lirc_config * mex_lirc_init (const gchar *name) { int lirc_fd, res; gchar *tmp; lirc_fd = lirc_init ((char *)name, 1); if (lirc_fd == -1) g_warning (G_STRLOC ": LIRC initialisation failed"); else { struct lirc_config *config = NULL; /* Load the default config */ tmp = g_build_filename (mex_get_data_dir (), "mex-lircrc", NULL); res = lirc_readconfig (tmp, &config, NULL); g_free (tmp); if (res == 0) { int flags; GIOChannel *channel; /* Set non-blocking flag */ flags = fcntl (lirc_fd, F_GETFL); fcntl (lirc_fd, F_SETFL, flags | O_NONBLOCK); /* Create IOChannel to do non-blocking reads */ channel = g_io_channel_unix_new (lirc_fd); g_io_add_watch (channel, G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_NVAL | G_IO_HUP, (GIOFunc)mex_lirc_read_cb, config); return config; } else { g_warning (G_STRLOC ": Error reading LIRC config"); lirc_deinit (); } } return NULL; }
/***************************************************************************** * Open: initialize interface *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys; /* Allocate instance and initialize some members */ p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; p_sys->i_fd = lirc_init( "vlc", 1 ); if( p_sys->i_fd == -1 ) { msg_Err( p_intf, "lirc initialisation failed" ); goto error; } /* We want polling */ fcntl( p_sys->i_fd, F_SETFL, fcntl( p_sys->i_fd, F_GETFL ) | O_NONBLOCK ); /* Read the configuration file */ char *psz_file = var_InheritString( p_intf, "lirc-file" ); int val = lirc_readconfig( psz_file, &p_sys->config, NULL ); free( psz_file ); if( val != 0 ) { msg_Err( p_intf, "failure while reading lirc config" ); lirc_deinit(); goto error; } if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { lirc_freeconfig( p_sys->config ); lirc_deinit(); goto error; } return VLC_SUCCESS; error: free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * Open: initialize interface *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys; char *psz_file; /* Allocate instance and initialize some members */ p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; p_intf->pf_run = Run; p_sys->i_fd = lirc_init( "vlc", 1 ); if( p_sys->i_fd == -1 ) { msg_Err( p_intf, "lirc initialisation failed" ); goto exit; } /* We want polling */ fcntl( p_sys->i_fd, F_SETFL, fcntl( p_sys->i_fd, F_GETFL ) | O_NONBLOCK ); /* Read the configuration file */ psz_file = var_CreateGetNonEmptyString( p_intf, "lirc-file" ); if( lirc_readconfig( psz_file, &p_sys->config, NULL ) != 0 ) { msg_Err( p_intf, "failure while reading lirc config" ); free( psz_file ); goto exit; } free( psz_file ); return VLC_SUCCESS; exit: if( p_sys->i_fd != -1 ) lirc_deinit(); free( p_sys ); return VLC_EGENERIC; }
static void module_init(Enna_Module *em) { struct lirc_config *config; int fd; if (!em) return; mod = calloc(1, sizeof(Enna_Module_Lirc)); if (!mod) return; mod->em = em; em->mod = mod; // initialize lirc if ((fd = lirc_init("enna", 1)) == -1) // TODO need to close this? or ecore_fd_hand_del is enoght? { enna_log(ENNA_MSG_ERROR, ENNA_MODULE_NAME, "could not initialize LIRC support"); return; } if (lirc_readconfig(NULL, &config, NULL) != 0) { lirc_deinit(); enna_log(ENNA_MSG_ERROR, ENNA_MODULE_NAME, "could not find Lirc config file"); return; } mod->lirc_config = config; // connect to the lirc socket fcntl(fd, F_SETFL, O_NONBLOCK); fcntl(fd, F_SETFD, FD_CLOEXEC); mod->fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _lirc_code_received, NULL, NULL, NULL); #if 0 // register the configuration panel _config_panel = enna_config_panel_register(_("Remote"), "icon/music", lirc_panel_show, lirc_panel_hide, NULL); #endif }
int main(int argc, char **argv) { int retcode; /** Init **/ if (lirc_init("lircE161",1)==-1) exit(EXIT_FAILURE); /* Init lirc_client */ if (lirc_readconfig( lirc_configfile, &lirc_config, NULL) !=0 ){ lirc_deinit(); return EXIT_FAILURE; } /* Get the command to run on command_buf */ strcpy(command_buf, getcommand(lirc_config)); /* build up the arguments in arf_buf at every key press */ while(1){ retcode = getnextlircinput(); if (retcode == LIRCE161_ERROR) goto out; if (retcode == LIRCE161_DONE) /* done, let get out and run */ break; } /* Put the command together */ sprintf(composite_buf, (const char *)command_buf, arg_buf); #ifdef DEBUG printf("Command is %s\n", command_buf); printf("Arguments are %s\n", arg_buf); printf("Composite Command is %s\n", composite_buf); #endif system(composite_buf); /* finish up */ out: lirc_freeconfig(lirc_config); lirc_deinit(); return EXIT_SUCCESS; }
int lirc_fbi_init() { int fd; if (-1 == (fd = lirc_init("fbi",debug))) { if (debug) fprintf(stderr,"lirc: no infrared remote support available\n"); return -1; } if (0 != lirc_readconfig(NULL,&config,NULL)) { config = NULL; } if (debug) fprintf(stderr, "lirc: ~/.lircrc file %sfound\n", config ? "" : "not "); fcntl(fd,F_SETFL,O_NONBLOCK); fcntl(fd,F_SETFD,FD_CLOEXEC); if (debug) fprintf(stderr,"lirc: init ok\n"); return fd; }
/***************************************************************************** * Open: initialize interface *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; int i_fd; /* Allocate instance and initialize some members */ p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); if( p_intf->p_sys == NULL ) { msg_Err( p_intf, "out of memory" ); return 1; } p_intf->pf_run = Run; i_fd = lirc_init( "vlc", 1 ); if( i_fd == -1 ) { msg_Err( p_intf, "lirc_init failed" ); free( p_intf->p_sys ); return 1; } /* We want polling */ fcntl( i_fd, F_SETFL, fcntl( i_fd, F_GETFL ) | O_NONBLOCK ); if( lirc_readconfig( NULL, &p_intf->p_sys->config, NULL ) != 0 ) { msg_Err( p_intf, "lirc_readconfig failed" ); lirc_deinit(); free( p_intf->p_sys ); return 1; } p_intf->p_sys->p_input = NULL; return 0; }
int main(int argc, char *argv[]) { struct lirc_config *config; int daemonize=0; progname="irexec-" VERSION; while(1) { int c; static struct option long_options[] = { {"help",no_argument,NULL,'h'}, {"version",no_argument,NULL,'v'}, #ifdef DAEMONIZE {"daemon",no_argument,NULL,'d'}, #endif {0, 0, 0, 0} }; c = getopt_long(argc,argv,"hvd",long_options,NULL); if(c==-1) break; switch (c) { case 'h': printf("Usage: %s [options] [config_file]\n",argv[0]); printf("\t -h --help\t\tdisplay this message\n"); printf("\t -v --version\t\tdisplay version\n"); #ifdef DAEMONIZE printf("\t -d --daemon\t\trun in background\n"); #endif return(EXIT_SUCCESS); case 'v': printf("%s\n",progname); return(EXIT_SUCCESS); #ifdef DAEMONIZE case 'd': daemonize=1; break; #endif default: printf("Usage: %s [options] [config_file]\n",argv[0]); return(EXIT_FAILURE); } } if (optind < argc-1) { fprintf(stderr,"%s: too many arguments\n",progname); return(EXIT_FAILURE); } if(lirc_init("irexec",daemonize ? 0:1)==-1) exit(EXIT_FAILURE); if(lirc_readconfig(optind!=argc ? argv[optind]:NULL,&config,NULL)==0) { char *code; char *c; int ret; #ifdef DAEMONIZE if(daemonize) { if(daemon(0,0)==-1) { fprintf(stderr,"%s: can't daemonize\n", progname); perror(progname); lirc_freeconfig(config); lirc_deinit(); exit(EXIT_FAILURE); } } #endif while(lirc_nextcode(&code)==0) { if(code==NULL) continue; while((ret=lirc_code2char(config,code,&c))==0 && c!=NULL) { #if defined(DAEMONIZE) && defined(DEBUG) if(!daemonize) { printf("Execing command \"%s\"\n",c); } #endif system(c); } free(code); if(ret==-1) break; } lirc_freeconfig(config); } lirc_deinit(); exit(EXIT_SUCCESS); }
/* This is our thread function. It is like main(), but for a thread*/ void *threadFunc(void *arg) { struct lirc_config *config; int buttonTimer = millis(); char *code; char *c; //Initiate LIRC. Exit on failure if(lirc_init("lirc",1)==-1) exit(EXIT_FAILURE); //Read the default LIRC config at /etc/lirc/lircd.conf This is the config for your remot$ if(lirc_readconfig(NULL,&config,NULL)==0) { //Do stuff while LIRC socket is open 0=open -1=closed. while(lirc_nextcode(&code)==0) { //If code = NULL, meaning nothing was returned from LIRC socket, //then skip lines below and start while loop again. if(code==NULL) continue; { if (millis() - buttonTimer > 400) { //Check to see if the string "KEY_#" appears anywhere within the string $ if(strstr (code,"KEY_F")) { printf("MATCH on KEY_F\n"); sLED(0,200,0,0); buttonTimer = millis(); } else if(strstr (code,"KEY_G")) { printf("MATCH on KEY_G\n"); MODE = 2; buttonTimer = millis(); } else if(strstr (code,"KEY_H")) { printf("MATCH on KEY_H\n"); MODE = 1; buttonTimer = millis(); } else if(strstr (code,"KEY_E")) { printf("MATCH on KEY_E\n"); sLED(0,0,100,0); buttonTimer = millis(); } else if(strstr (code,"KEY_A")) { printf("MATCH on KEY_A\n"); sLED(0,0,0,0); buttonTimer = millis(); } } } //Need to free up code before the next loop free(code); } //Frees the data structures associated with config. lirc_freeconfig(config); } //lirc_deinit() closes the connection to lircd and does some internal clean-up stuff. lirc_deinit(); //exit(EXIT_SUCCESS); return NULL; }
//Main function int main(int argc, char* argv[]) { //LIRC Variables struct lirc_config *config; //HTTP Variables char *host = "10.0.0.2"; char *http_request_format = "POST /php/remote_control_api.php HTTP/1.1\n" "Host: 10.0.0.2\n" "Content-Type: application/x-www-form-urlencoded\n" "Content-Length: 10\n\n" "function=%s\n"; char http_request[MAX_HTTP_REQUEST_LEN]; char http_response[MAX_HTTP_RESPONSE_LEN]; //Socket Variables int sockfd, error; struct addrinfo hints, *addrinfo_list, *addrinfo; //Misc Variables int valid_key = 0; struct timeval tv; gettimeofday(&tv, NULL); time_t start_time = tv.tv_sec, end_time, time_delay; //Outputs usage and exits if given more than one file path in arguments if (argc>2) { fprintf(stderr, "Usage: %s <config file>\n", argv[0]); return -1; } //Initializes LIRC and exits if unsuccessful, called at start of execution if (lirc_init("lirc",1)==-1) { fprintf(stderr, "lirc_init: failed to initialize lirc\n"); return -1; } //Clears hints structure and set appropriately for call to getaddrinfo() memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; //Gets the linked list of possible addrinfo structures if (error = getaddrinfo(host, PORT, &hints, &addrinfo_list) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error)); return -1; } //Iterate through linked list of possible addrinfo structures and attempts to create socket to connect to for (addrinfo = addrinfo_list; addrinfo != NULL; addrinfo = addrinfo->ai_next) { //Creates a socket if ((sockfd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) == -1) { continue; } //Connect to socket if (connect(sockfd, addrinfo->ai_addr, addrinfo->ai_addrlen) == -1) { close(sockfd); continue; } //Break out of loop if calls to socket() and connect() are both successful break; } //If none of the addrinfo structures in the linked list works, then exit program if (addrinfo == NULL) { fprintf(stderr, "failed to connect to %s\n", host); return -1; } fprintf(stdout, "connection to %s was successful\n\n", host); close(sockfd); //Read in configuration file from either argument or default path if (lirc_readconfig(argc==2 ? argv[1]:NULL, &config, NULL) == 0) { char *code; //Used to store the key code of the remote //Blocks the program until an IR signal is recieved from key press while (lirc_nextcode(&code)==0) { //Handle logic key press, if any if (code==NULL) continue; { gettimeofday(&tv, NULL); end_time = tv.tv_sec; printf("Starttime=%ld\tEndtime=%ld\n\n", start_time, end_time); if (end_time - start_time > DELAY) { //Clears request and response buffer memset(&http_request, 0, sizeof http_request); memset(&http_response, 0, sizeof http_response); if (strstr(code,"KEY_POWER")) { if ((valid_key = handle_key_power(http_request, http_request_format)) == -1) { return -1; } } else if (strstr(code,"KEY_STOP")) { if ((valid_key = handle_key_stop(http_request, http_request_format)) == -1) { return -1; } } else if (strstr(code,"KEY_PAUSE")) { if ((valid_key = handle_key_pause(http_request, http_request_format)) == -1) { return -1; } } else if (strstr(code,"KEY_PLAY")) { if ((valid_key = handle_key_play(http_request, http_request_format)) == -1) { return -1; } } else if (strstr(code,"KEY_REWIND")) { if ((valid_key = handle_key_rewind(http_request, http_request_format)) == -1) { return -1; } } else if (strstr(code,"KEY_FORWARD")) { if ((valid_key = handle_key_forward(http_request, http_request_format)) == -1) { return -1; } } if (valid_key) { //Creates socket if ((sockfd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) == -1) { return -1; } //Connect to socket if (connect(sockfd, addrinfo->ai_addr, addrinfo->ai_addrlen) == -1) { close(sockfd); return -1; } if (send_http_request(sockfd, http_request) == -1) { fprintf(stderr, "An error has occur while sending the HTTP request\n"); } else { fprintf(stdout, "HTTP request has been sent successfully.\n" "--------------------------------------------------\n" "%s\n\n", http_request); } if (receive_http_response(sockfd, http_response) == -1) { fprintf(stderr, "An error has occur while receiving the HTTP response\n"); } else { fprintf(stdout, "HTTP response has been received successfully.\n" "--------------------------------------------------\n" "%s\n\n", http_response); } close(sockfd); } gettimeofday(&tv, NULL); start_time = tv.tv_sec; } } free(code); //Free allocated memory for code after key press is handled } lirc_freeconfig(config); //Free allocated memory for configuration structure } //Deallocate memory from linked list of addrinfo structures freeaddrinfo(addrinfo_list); lirc_deinit(); //Deinitializes LIRC, called at end of program execution return 0; //EXIT_SUCCESS } //end of main()
int main(int argc, char *argv[]) { char keyname[128]; int pointer_button,pointer_x,pointer_y; char windowname[64]; struct lirc_config *config; progname=argv[0]; if(argc>2) { fprintf(stderr,"Usage: %s <config file>\n",argv[0]); exit(1); }; dpy=XOpenDisplay(NULL); if(dpy==NULL) { fprintf(stderr,"Can't open DISPLAY.\n"); exit(1); } root=RootWindow(dpy,DefaultScreen(dpy)); if(lirc_init("irxevent",1)==-1) exit(EXIT_FAILURE); if(lirc_readconfig(argc==2 ? argv[1]:NULL,&config,check)==0) { char *ir; char *c; int ret; while(lirc_nextcode(&ir)==0) { if(ir==NULL) continue; while((ret=lirc_code2char(config,ir,&c))==0 && c!=NULL) { debugprintf("Recieved code: %sSending event: ",ir); if(2==sscanf(c,"Key %s %s\n",keyname,windowname)) { if((w=find_window(root,windowname))) { debugprintf("keyname: %s \t windowname: %s\n",keyname,windowname); sendkey(keyname,1,1,w,0); } else { debugprintf("target window '%s' not found \n",windowname); } } else if(4==sscanf(c,"Button %d %d %d %s\n", &pointer_button,&pointer_x, &pointer_y,windowname)) { if((w=find_window(root,windowname)) && (subw=find_sub_window(root,windowname,&pointer_x,&pointer_y))) { if (w==subw) subw=0; debugprintf(" %s\n",c); sendbutton(pointer_button,pointer_x,pointer_y,w,subw); } else { debugprintf("target window '%s' not found \n",windowname); } } else if(4==sscanf(c,"xy_Key %d %d %s %s\n", &pointer_x,&pointer_y, keyname,windowname)) { if((w=find_window(root,windowname))&& (subw=find_sub_window(root,windowname,&pointer_x,&pointer_y))) { debugprintf(" %s\n",c); if (w==subw) subw=0; sendkey(keyname,pointer_x,pointer_y,w,subw); } else { debugprintf("target window '%s' not found \n",windowname); } } } free(ir); if(ret==-1) break; } lirc_freeconfig(config); } lirc_deinit(); exit(0); }
int main(int argc, char* argv[]) { int fdm, c, ignoreeof, interactive, noecho, verbose; pid_t pid; char* config; char slave_name[20]; struct termios orig_termios; struct winsize size; int flags; interactive = isatty(STDIN_FILENO); ignoreeof = 0; noecho = 0; verbose = 0; config = NULL; while ((c = getopt_long(argc, argv, "hVs:einv", long_options, NULL)) != EOF) { switch (c) { case 'h': printf("Usage: %s [options] config_file -- program [args ...]\n", argv[0]); printf("\t -h --help \t\tdisplay usage summary\n"); printf("\t -V --version \t\tdisplay version\n"); printf("\t -e --no-echo \t\tdisable echo\n"); printf("\t -i --ignore-eof \tignore EOF\n"); printf("\t -n --non-interactive \tforce non-interactive mode\n"); printf("\t -v --verbose \t\tverbose mode\n"); return EXIT_SUCCESS; case 'V': printf("irpty %s\n", VERSION); return EXIT_SUCCESS; case 'e': noecho = 1; break; case 'i': ignoreeof = 1; break; case 'n': interactive = 0; break; case 'v': verbose = 1; break; case '?': die("unrecognized option: -%c\n", optopt); } } if (optind + 1 >= argc) die("usage: irpty [ -s server -einv ] cfg program [ arg ... ]\n"); config = argv[optind++]; if ((lsock = lirc_init("irpty", 1)) == -1) exit(EXIT_FAILURE); flags = fcntl(lsock, F_GETFL, 0); if (flags != -1) fcntl(lsock, F_SETFL, flags | FASYNC | O_NONBLOCK); if (lirc_readconfig(config, &lconfig, NULL) != 0) exit(EXIT_FAILURE); if (interactive) { if (tcgetattr(STDIN_FILENO, &orig_termios) < 0) die("tcgetattr error on stdin\n"); if (ioctl(STDIN_FILENO, TIOCGWINSZ, (char*)&size) < 0) die("TIOCGWINSZ error\n"); pid = pty_fork(&fdm, slave_name, &orig_termios, &size); } else { pid = pty_fork(&fdm, slave_name, NULL, NULL); } if (pid < 0) { die("fork error\n"); } else if (!pid) { /* child */ if (noecho) set_noecho(STDIN_FILENO); /* stdin is slave pty */ if (execvp(argv[optind], &argv[optind]) < 0) die("can't execute: %s\n", argv[optind]); } if (verbose) { fprintf(stderr, "slave name = %s\n", slave_name); if (config) fprintf(stderr, "config file = %s\n", config); } if (interactive) { if (tty_raw(STDIN_FILENO) < 0) /* user's tty to raw mode */ die("tty_raw error"); if (atexit(tty_atexit) < 0) /* reset user's tty on exit */ die("atexit error"); } copy_loop(fdm, ignoreeof); exit(0); }
int main(int argc, char* argv[]) { char keyname[128]; int pointer_button, pointer_x, pointer_y; char windowname[64]; struct lirc_config* config; char* config_file = NULL; int c; unsigned int WindowID; while ((c = getopt_long(argc, argv, "dhV", long_options, NULL)) != EOF) { switch (c) { case 'd': bDaemon = 1; continue; case 'h': printf("Usage: %s [option]... [config file]\n" " -d --daemon fork and run in background\n" " -h --help display usage summary\n" " -V --version display version\n", prog); return EXIT_SUCCESS; case 'V': printf("%s %s\n", prog, VERSION); return EXIT_SUCCESS; case '?': fprintf(stderr, "unrecognized option: -%c\n", optopt); fprintf(stderr, "Try `%s --help' for more information.\n", prog); return EXIT_FAILURE; } } if (argc == optind + 1) { config_file = argv[optind]; } else if (argc > optind + 1) { fprintf(stderr, "%s: incorrect number of arguments.\n", prog); fprintf(stderr, "Try `%s --help' for more information.\n", prog); return EXIT_FAILURE; } dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "Can't open DISPLAY.\n"); exit(1); } root = RootWindow(dpy, DefaultScreen(dpy)); // windows may get closed at wrong time. Override default error handler... XSetErrorHandler(errorHandler); if (lirc_init("irxevent", 1) == -1) exit(EXIT_FAILURE); if (lirc_readconfig(config_file, &config, check) == 0) { char* ir; char* c; int ret; if (bDaemon) { if (daemon(1, 0) < 0) { perror("Failed to run as daemon"); exit(EXIT_FAILURE); } } while (lirc_nextcode(&ir) == 0) { if (ir == NULL) continue; while ((ret = lirc_code2char(config, ir, &c)) == 0 && c != NULL) { log_debug("Received code: %s Sending:\n", ir); bInError = 0; // reset error state, want to see error msg *windowname = 0; if (2 == sscanf(c, "Key %s Focus WindowID %i", keyname, &WindowID) || 4 == sscanf(c, "Button %d %d %d Focus WindowID %i", &pointer_button, &pointer_x, &pointer_y, &WindowID) || 4 == sscanf(c, "xy_Key %d %d %s Focus WindowID %i", &pointer_x, &pointer_y, keyname, &WindowID) || 2 == sscanf(c, "Key %s Focus %s", keyname, windowname) || 4 == sscanf(c, "Button %d %d %d Focus %s", &pointer_button, &pointer_x, &pointer_y, windowname) || 4 == sscanf(c, "xy_Key %d %d %s Focus %s", &pointer_x, &pointer_y, keyname, windowname)) { log_debug("Focus\n"); /* focussed ? */ if (*windowname) { WindowID = find_window_focused(root, windowname); if (!WindowID) { log_debug("target window '%s' doesn't have focus\n", windowname); continue; } log_debug("focused: %s\n", windowname); } else { Window cur; int tmp; XGetInputFocus(dpy, &cur, &tmp); if (WindowID != cur) { log_debug("target window '0x%x' doesn't have focus\n", WindowID); continue; } log_debug("focused: 0x%x\n", WindowID); } } else if (2 == sscanf(c, "Key %s WindowID %i", keyname, &WindowID) || 4 == sscanf(c, "Button %d %d %d WindowID %i", &pointer_button, &pointer_x, &pointer_y, &WindowID) || 4 == sscanf(c, "xy_Key %d %d %s WindowID %i", &pointer_x, &pointer_y, keyname, &WindowID)) { log_debug("WindowID: 0x%x\n", WindowID); /* WindowID passed */ } else if (2 == sscanf(c, "Key %s %s", keyname, windowname) || 4 == sscanf(c, "Button %d %d %d %s", &pointer_button, &pointer_x, &pointer_y, windowname) || 4 == sscanf(c, "xy_Key %d %d %s %s\n", &pointer_x, &pointer_y, keyname, windowname)) { log_debug("name: %s\n", windowname); WindowID = find_window(root, windowname); if (WindowID == 0) { log_debug("target window '%s' not found\n", windowname); continue; } } switch (c[0]) { case 'K': // Key log_debug("keyname: %s \t WindowID: 0x%x\n", keyname, WindowID); log_debug("%s\n", c); sendkey(keyname, 1, 1, (Window)WindowID, 0); break; case 'B': // Button case 'x': // xy_Key subw = find_sub_window(root, windowname, &pointer_x, &pointer_y); if (subw) { if (WindowID == subw) subw = 0; log_debug("%s\n", c); switch (c[0]) { case 'B': /* FIXME: pointer_button potentially uninititalzed. */ sendbutton(pointer_button, pointer_x, pointer_y, WindowID, subw); break; case 'x': sendkey(keyname, pointer_x, pointer_y, WindowID, subw); break; } } break; } } free(ir); if (ret == -1) break; } lirc_freeconfig(config); } lirc_deinit(); exit(0); }
/** * Initialize the driver. * \param drvthis Pointer to driver structure. * \retval 0 Success. * \retval <0 Error. */ MODULE_EXPORT int lircin_init (Driver *drvthis) { char s[256] = ""; PrivateData *p; /* Alocate and store private data */ p = (PrivateData *) malloc(sizeof(PrivateData)); if (p == NULL) { report(RPT_ERR, "%s: Could not allocate private data", drvthis->name); return -1; } if (drvthis->store_private_ptr(drvthis, p)) { report(RPT_ERR, "%s: Could not store private data", drvthis->name); return -1; } /* Initialise the PrivateData structure */ p->lircrc = NULL; p->prog = NULL; p->lircin_irconfig = NULL; p->lircin_fd = -1; /* READ CONFIG FILE:*/ /* Get location of lircrc to be used */ if (drvthis->config_get_string(drvthis->name, "lircrc", 0 , NULL) != NULL) { strncpy(s, drvthis->config_get_string(drvthis->name, "lircrc", 0, ""), sizeof(s)); s[sizeof(s)-1] = '\0'; } if (*s != '\0') { p->lircrc = malloc(strlen(s) + 1); if (p->lircrc == NULL) { report(RPT_ERR, "%s: Could not allocate new memory", drvthis->name); return -1; } strcpy(p->lircrc, s); report(RPT_INFO,"%s: Using lircrc: %s", drvthis->name, p->lircrc); } else { report(RPT_INFO,"%s: Using default lircrc: ~/.lircrc", drvthis->name); } /* Get program identifier "prog=..." to be used */ strncpy(s, drvthis->config_get_string(drvthis->name, "Prog", 0, LIRCIN_DEF_PROG), sizeof(s)); p->prog = malloc(strlen(s) + 1); if (p->prog == NULL) { report(RPT_ERR, "%s: Could not allocate new memory", drvthis->name); return -1; } strcpy(p->prog, s); report(RPT_INFO, "%s: Using prog: %s", drvthis->name, p->prog); /* End of config file parsing */ /* open socket to lirc */ if (-1 == (p->lircin_fd = lirc_init(p->prog, LIRCIN_VERBOSELY))) { report(RPT_ERR, "%s: Could not connect to lircd", drvthis->name); lircin_close(drvthis); return -1; } if (0 != lirc_readconfig(p->lircrc, &p->lircin_irconfig, NULL)) { report(RPT_ERR, "%s: lirc_readconfig() failed", drvthis->name); lircin_close(drvthis); return -1; } /* socket shouldn't block lcdd */ if (fcntl(p->lircin_fd, F_SETFL, O_NONBLOCK) < 0){ report(RPT_ERR, "%s: Unable to change lircin_fd(%d) to O_NONBLOCK: %s", drvthis->name, p->lircin_fd, strerror(errno)); lircin_close(drvthis); return -1; } fcntl (p->lircin_fd, F_SETFD, FD_CLOEXEC); report(RPT_DEBUG, "%s: init() done", drvthis->name); return 0; }
void master_irda::run() { c_irda_logic irda_queue(my_data2); //Read the default LIRC config at /etc/lirc/lircd.conf This is the config for your remote. if(lirc_readconfig(NULL,&config,NULL)==0) { // std::cout << " jestem w iflirc_readconfig(NULL,&config,NULL)==0 \n "; //Do stuff while LIRC socket is open 0=open -1=closed. while(lirc_nextcode(&code)==0 ) { std::cout << " w while \n"; if (go_while==false) /// TO NIE DZIALA DO POPRAWY { break; // koncze petle zamykam wątek } //If code = NULL, meaning nothing was returned from LIRC socket, //then skip lines below and start while loop again. if(code==NULL) { std::cout << " kontynuuje\n"; continue;} { //Make sure there is a 400ms gap before detecting button presses. if (millis() - buttonTimer > 400 ){ digitalWrite(BUZZER,ON); // time out OK menu if (millis() - buttonTimer > 30000 && buttonMENU == 1){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " timeout menu " << std::endl; log_file_mutex.mutex_unlock(); buttonMENU=0; // flaga na 0 nie wejdze juz do timeout irda_queue._add('e'); } ////////////////////////////////////////////////////////////// //Check to see if the string "KEY_1" appears anywhere within the string 'code'. if(strstr (code,"KEY_POWER")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " wcisnieto POWER" << std::endl; log_file_mutex.mutex_unlock(); irda_queue._add('P'); buttonTimer = millis(); } else if(strstr (code,"KEY_1")){ irda_queue._add('1'); buttonTimer = millis(); } else if(strstr (code,"KEY_2")){ irda_queue._add('2'); buttonTimer = millis(); } else if(strstr (code,"KEY_3")){ irda_queue._add('3'); //my_data2->mainLCD->printString(1,1,"klawisz 3"); buttonTimer = millis(); } else if(strstr (code,"KEY_4")){ irda_queue._add('4'); buttonTimer = millis(); } else if(strstr (code,"KEY_5")){ irda_queue._add('5'); buttonTimer = millis(); } else if(strstr (code,"KEY_6")){ irda_queue._add('6'); buttonTimer = millis(); } else if(strstr (code,"KEY_7")){ irda_queue._add('7'); buttonTimer = millis(); } else if(strstr (code,"KEY_8")){ irda_queue._add('8'); buttonTimer = millis(); } else if(strstr (code,"KEY_9")){ irda_queue._add('9'); buttonTimer = millis(); } else if(strstr (code,"KEY_0")){ irda_queue._add('0'); buttonTimer = millis(); } //////////////////////////////////// else if(strstr (code,"KEY_INFO")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " operacja na diodzie" << std::endl; log_file_mutex.mutex_unlock(); irda_queue._add('I'); buttonTimer = millis(); } ///////////////////////////////////////////////// else if(strstr (code,"KEY_TV")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " wcisnieto PLAY" << std::endl; log_file_mutex.mutex_unlock(); irda_queue._add('t'); buttonTimer = millis(); } else if(strstr (code,"KEY_AUDIO")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " wcisnieto PAUSE" << std::endl; log_file_mutex.mutex_unlock(); irda_queue._add('A'); buttonTimer = millis(); } else if(strstr (code,"KEY_VOLUMEUP")){ irda_queue._add('+'); buttonTimer = millis(); } else if(strstr (code,"KEY_VOLUMEDOWN")){ irda_queue._add('-'); buttonTimer = millis(); } ///////////////////////////////////////////// else if(strstr (code,"KEY_DOWN")){ irda_queue._add('D'); buttonTimer = millis(); } else if(strstr (code,"KEY_UP")){ irda_queue._add('U'); buttonTimer = millis(); } else if(strstr (code,"KEY_OK")){ irda_queue._add('O'); buttonMENU=0; buttonTimer = millis(); } else if(strstr (code,"KEY_MENU")){ irda_queue._add('M'); buttonMENU=1;// wlacz timeout dla menu buttonTimer = millis(); } else if(strstr (code,"KEY_EXIT")){ irda_queue._add('e'); buttonMENU = 0; buttonTimer = millis(); } else if(strstr (code,"KEY_RADIO")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " sterowanie projektorem" << std::endl; log_file_mutex.mutex_unlock(); irda_queue._add('r'); //idziemy do sterowania projektorem buttonTimer = millis(); } else if(strstr (code,"KEY_EPG")){ log_file_mutex.mutex_lock(); log_file_cout << INFO<< " przegladanie katalogu z filmami" << std::endl; log_file_mutex.mutex_unlock(); buttonMENU=1; irda_queue._add('E'); //idziemy do sterowania projektorem buttonTimer = millis(); } else if(strstr (code,"KEY_CHANNELUP")){ irda_queue._add('^'); buttonTimer = millis(); } else if(strstr (code,"KEY_CHANNELDOWN")){ irda_queue._add('/'); buttonTimer = millis(); } else if(strstr (code,"KEY_MUTE")){ irda_queue._add('m'); buttonTimer = millis(); } else if(strstr (code,"KEY_FAVORITES")){ irda_queue._add('F'); buttonTimer = millis(); } else if(strstr (code,"KEY_REFRESH")){ irda_queue._add('R'); buttonTimer = millis(); } else if(strstr (code,"KEY_LANGUAGE")){ irda_queue._add('L'); buttonTimer = millis(); } else if(strstr (code,"KEY_SUBTITLE")){ irda_queue._add('S'); buttonTimer = millis(); } else if(strstr (code,"KEY_SAT")){ irda_queue._add('s'); buttonTimer = millis(); } else if(strstr (code,"KEY_TEXT")){ irda_queue._add('T'); buttonTimer = millis(); } } } //Need to free up code before the next loop free(code); digitalWrite(BUZZER,OFF); } //Frees the data structures associated with config. lirc_freeconfig(config); } log_file_mutex.mutex_lock(); log_file_cout << INFO << " koniec watku master IRDA "<< std::endl; log_file_mutex.mutex_unlock(); //lirc_deinit() closes the connection to lircd and does some internal clean-up stuff. lirc_deinit(); // exit(EXIT_SUCCESS); }