Coder Social home page Coder Social logo

bengtmartensson / devslashlirc Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 4.0 773 KB

Object oriented access to /dev/lirc-hardware from C++ and Java

Home Page: http://www.harctoolbox.org/

License: GNU General Public License v3.0

Makefile 6.87% C 6.67% C++ 51.52% Java 34.16% Shell 0.43% XSLT 0.35%
lirc linux infrared ir-signal jni java

devslashlirc's Introduction

DevSlashLirc โ€” Object oriented access to /dev/lirc-hardware.

API documentation

Introduction

This library makes objects from /dev/lirc-hardware. These objects have properties like canSend etc., indicating the capabilities of the currently connected hardwarec, and methods like send and receive for sending and receiving. See the examples in src/test/c++.

As opposed to standard C/Lirc, where a device is opened, and it "turns out" that it is "mode2" or "lirccode", here the user has to decide if he wants a mode2 or lirccode device, and open it with the appropriate class. This will fail if the connected hardware does not have the expected properties. For this, there are the concrete classes Mode2LircDevice (modeling a "mode2" device, i.e. with the possibility of handling IR signals with "arbitrary" timings), and LircCodeLircDevice (modeling a "LircCode" device, i.e. one that can only use IR signals from its own set, and codes them on an integer, representing the IR signal.) The latter class is presently not completely implemented.

The classes may be instantiated multiple times, but of course only one can open a particular device file at a particular time.

The core library is written in C++, using classes and the stdc++ library. There are no other dependencies. In particular, there is no dependency of the Lirc sources, includes, or libraries. Only media/lirc.h, see man 4 lirc, which is considered belonging to the kernel, is included. The C++ code is documented using doxygen.

The C++-code uses the ("non-portable") #pragma once instead of the traditional include guards.

The C++ code is compiled into a shared library. This can be linked into application programs (see the test programs in src/test/c++) or used as a JNI library for accessing it from Java. Also a static library is built.

As man 4 lirc shows, there is a large number of hardly ever implemented properties supported. I have followed the "agile" commandment maximize the amount of work not done, and simply ignored the ones not useful or not commonly implemented.

As mentioned, there are also Java bindings using JNI. With some extra effort, bindings from other languages can be added, for example using SWIG. Contributions are welcome, (see issue #1).

The code should compile on any platform supporting /dev/lirc, possibly after adapting the Makefile (see issue #2).

A natural extension would be to extend the library to support Lirc plugin drivers. This is discussed in issue #3). There is also a branch containing some work in this directon, lircdriver.

Maven is used to compile the Java parts. A Makefile compiles the C++ code, and also invokes the Maven process. Redundantly, to build, just issue the command

 make lib

On an x86_64, this will build the libraries for x86_32 and x86_64. To build for another architecture without using a cross compiler, log in to an appropriate host, cd to src/main/c++, and issue the command

make clean all

on that host. Then copy the thus created libdevslashlirc.so to a desired location.

The command

make doc

creates the Doxygen and Javadoc documentation.

The code is entirely written from scratch (not counting the branch lircdriver).

Usage

There is no "install". Just copy the so file, the jar file, and possibly the *.h files to anywhere you like. (Or use maven instead for the jar file.)

For C++ (or a similar language), just link with the shared library libdevslashlirc.so (alternatively the static library libdevslashlirc.a) in the usual manner.

For Java, copy libdevslashlirc.so to an "arbitrary" location. In the Java code, that library must be loaded with org.harctoolbox.devslashlirc.LircHardware.loadLibrary(). There are two possibilites:

  1. Either call loadLibrary() without arguments, (see src/test/java/org/harctoolbox/devslashlirc/Mode2LircDeviceNGTest.java for an example), in which case the actual directory has to be given to the JVM using the -Djava.library.path option (like java -Djava.library.path=/usr/local/lib ...), or,

  2. Call loadLibrary(File) with argument, either the path name of the library, or the path name of the containing directory. For example LircHardware.loadLibrary(new File("/home/trump/covfefe/libdevslashlirc.so")).

devslashlirc's People

Contributors

bengtmartensson avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

devslashlirc's Issues

Compile the driver on an raspberry pi :)

apt-get install maven oracle-java7-jdk
exchange the makefile i attached in /src/main/c++
Id had to change/add some includes

Makefile.zip

The only thing id got stuck is to install the built. Could you please help me with that?
It would be quite awesome to use the driver on a raspberry pi because the current liblirc isnt ported currently for the Rpi.

Support Lirc plugin drivers

A natural extension would be to support Lirc dynamically loaded drivers, "plugins". I have actually spent quite some time on this, contained in the branch lircdriver. There are massive problems, basically due to the bad design of the Lirc drivers, resulting (among other things) in loader problems. The C++ version works reasonably, while the Java bindings suffer from loader problems, and does not find symbols. Possibly it is a Java problem?

write(2)-errors to /dev/lirc are not transmitted to Java

JNIEXPORT void JNICALL Java_org_harctoolbox_devslashlirc_Mode2LircDevice_sendNative(....) returns void, may be enough to change to jboolean.

The following signals is too long (?), and fails silently using IrScrutinizer

0000 006C 002A 0000 015B 00AD 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 015B 0057 0016 0E6C 015B 0057 0016 0E6C 015B 0057 0016 0E6C 015B 0057 0016 0E6C

Fix/check timing on final silence

Silly method presently deployed in bool Mode2LircDevice::send(const lirc_t *data, unsigned length).

Problems with repeating NEC1-signals, for example from IrScrutinizer: timing of final gap of into is off.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.