npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lirc_client

v1.0.0

Published

An lirc_client object for nodejs

Downloads

37

Readme

NPM

Description

node-lirc_client provides a lirc_client object so your nodejs application can receive lirc command.

It is based on the lirc_client example

Installation

npm install lirc_client

Requirements

  • node.js -- v0.10.0+
  • lirc -- v0.9.0
    • lirc-devel(Fedora based), liblircclient-dev(raspbian), liblircclient-dev(Ubuntu) package is required for lirc_client.h header file.

Example

var lirc_client = require('lirc_client');

try {
	lirc_client.connect("testone", true, "test1.lircrc",function(type, data, configFile){
		console.log("Type:", type);
		console.log("Data:", data);
		switch (type) {
			case "rawdata":
				console.log("Rawdata received:",data);
				break;
			case "data":
				console.log("Data received '%s' from configFile '%s'",data, configFile);
				break;
			case "closed":
				console.log("Lircd closed connection to us.");
				break;
		}
	});

	console.log("lirc_client.isConnected:", lirc_client.isConnected);
	console.log("lirc_client.mode:", lirc_client.mode);
	console.log("lirc_client.configFiles:", lirc_client.configFiles);

	console.close();
	console.log("lirc_client.isConnected:", lirc_client.isConnected);
}
catch (err) {
	console.log("Error on connect:",err);
}

See examples folder for more detailed example.

API Documentation

Module Functions

  • connect(< String >programName, [< Boolean >verbose], [< String >configFiles], < Function >callback(< String >type[, < String >data[, < String >configFile]])) - Should be called to connect to lircd.

  • connect(< String >programName, [< Boolean >verbose], [< Array >configFiles], < Function >callback(< String >type[, < String >data[, < String >configFile]])) - Should be called to connect to lircd.

    • < String >programName - Is the program name used to select right button in lircrc config files. Will be matched by lirc against the "prog" attribute. (.lircrc file format)
    • < Boolean >verbose - Will put the lirc library in verbose mode or not.
    • < String >configFiles - Specify full or relative path to an existing lircrc file. (.lircrc file format). When undefined then the lirc default config files /etc/lirc/lircrc and ~/.lircrc will be loaded.
    • < Array >configFiles - Array of < String > values. Each strings is a full or relative path to an existing lircrc file. (.lircrc file format). When undefined then the lirc default config files /etc/lirc/lircrc and ~/.lircrc will be loaded.
    • < Function >callback(< String >type[, < String >data[, < String >configFile]]) - Callback function which gets called when data is available or connection to lircd was closed outside of our control.
      • < String >type - Specifies why the callback function was called. Following values are possible:
        • "rawdata" - Means data argument contains raw data from lircd.conf file.
        • "data" - Means data argument contains config attribute from lircrc button which matches received ir button and prog attribute from lirrc file(s) and configFile will contain name of configFile as specified in connect or addConfig.
        • "closed" - Means connection to lircd was closed outside of our control.
      • Will throw errors when something fails.
  • close() - Closes the connection to lircd for this object.

  • reConnect() - Reconnects a closed connection to the lircd for this object. It will reuse arguments from connect call.

    • Will throw errors when something fails.
  • addConfig(< String >configFile | < Array >configFiles) - Add one or more lircrc config files.

    • < String >configFile - Must contain the full or relative path to an existing lircrc file.
    • < Array >configFiles - Is an array of String values. Each string must contain the full or relative path to an existing lircrc file.
  • clearConfig() - Will remove all lircrc config files from object. No more "data" events will be emited until at least one config has been added again.

Module properties

  • < Boolean >isConnected (read only) - When true is returned there is a connection to the lircd and the object will receive events. When false is returned the object is not connected to lircd and it will not receive events.

  • < String >mode (read/write) - Will perform lirc_getmode and lirc_setmode. Are not described on lirc website but were found in lirc_client.h file and on following page

  • < Array >configFiles (read only) - Will contain a list with config filenames currently active. When array is empty the lirc default lircrc config files are used.