RemoteMaster on Raspberry Pi with Raspian

Discussion forum for JP1 software tools currently in use, or being developed, such as IR, KM, RemoteMaster, and other misc apps/tools.

Moderator: Moderators

Post Reply
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

RemoteMaster on Raspberry Pi with Raspian

Post by Barf »

Since I recently got IrScrutinizer running on Raspberry Pi, ("RPi") running Raspian Jessie I thought I should look at having RemoteMaster running on said hardware. (IrScrutinizer 1.3 fully supports the RPi with Raspian Jessie, although it takes 30 seconds to start on a RPi 3.)

Since RM is written in Java, only the shared libraries needs investigation. Since RM searches for these in os.name . os.arch this amounts to a subdirectory Linux-arm. (Note that this is not sufficiently fine-grained for some applications: there are ARM processors of different versions, with and without hardware floating-point. For our purposes, it is good enough though. IIRC, the RPi 2 and 3 uses ARM version 7 with hardware FP.)

First step is thus to create the directory Linux-arm. Binaries for jp12serial is available here, DecodeIR 2.45 here. hidapi in two different versions can be installed using Raspian apt-get (packet names libhidapi-libusb0 and
libhidapi-hidraw0 ) For RM to find it, I made a symblic link, e.g.

Code: Select all

cd Linux-arm
ln -s /usr/lib/arm-linux-gnueabihf/libhidapi-libusb.so.0.0.0 libhidapi.so
It turns out that jp12serial and DecodeIR works fine, but for some reason I was not able to get the hidapi stuff to work. It failed to find and download a Nevo C2. This is (an except of) rmaster.err:

Code: Select all

LibraryLoader: Loaded 'DecodeIR' successfully from '/home/bengt/jp1/controlremote-code/km/Linux-arm/libDecodeIR.so'
Starting normal download
Interface Name = CommHID
Port Name = /dev/xsight
Testing interface: JP1.X Serial
Testing interface: CommHID
Interface matched.  Trying to open remote.
Download error: com.codeminders.hidapi.HIDManager.init()V
java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: com.codeminders.hidapi.HIDManager.init()V
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:188)
        at javax.swing.SwingWorker.get(SwingWorker.java:602)
        at com.hifiremote.jp1.RemoteMaster$DownloadTask.done(RemoteMaster.java:691)
        at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
        at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
        at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
        at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
        at javax.swing.Timer.fireActionPerformed(Timer.java:312)
        at javax.swing.Timer$DoPostEvent.run(Timer.java:244)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
        at java.awt.EventQueue.access$300(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:706)
        at java.awt.EventQueue$3.run(EventQueue.java:704)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.UnsatisfiedLinkError: com.codeminders.hidapi.HIDManager.init()V
        at com.codeminders.hidapi.HIDManager.init(Native Method)
        at com.codeminders.hidapi.HIDManager.<init>(HIDManager.java:53)
        at com.codeminders.hidapi.HIDManager.getInstance(HIDManager.java:121)
        at com.hifiremote.jp1.io.CommHID.getPIDofAttachedRemote(CommHID.java:44)
        at com.hifiremote.jp1.io.CommHID.openRemote(CommHID.java:213)
        at com.hifiremote.jp1.RemoteMaster.testInterface(RemoteMaster.java:3362)
        at com.hifiremote.jp1.RemoteMaster.getOpenInterface(RemoteMas
...
I guess it would be possible for me (or someone else) to find and fix, but for the moment I do not feel sufficiently motivated...

Bottom line: RM works on RPi, with the exception of hdiapi. It takes 50 seconds to start though (using OpenJDK Runtime Environment (IcedTea 2.6.6) (java version "1.7.0_101"). (May be faster with other Java implementations.)
TiceRex
Posts: 80
Joined: Thu Jun 28, 2012 11:37 pm

RPi4

Post by TiceRex »

Hi Barf,

Thank you very much for your efforts to make it work on RPi!

I can confirm, that RemoteMaster is working properly on RPi4 (8GB) model. I'm using it with M.2 card as system disk, so file access time could not be an issue. However, the startup time can be decreased significantly by deleting unnecessary remotes from the Images and RDF directories.

I haven't tried to download/upload from/to any remote control device yet, but the editors (both RMIR and RMDU) are working flawlessly.
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

Nice to hear. What Java version where you using (as per java -version). Although the challenging part is of course the deployment of the shared JNI libraries, in particular up- and downloads.
TiceRex
Posts: 80
Joined: Thu Jun 28, 2012 11:37 pm

Post by TiceRex »

Sorry, I didn't have time to test it recently.
Now I can confirm that the whole package (including upload/download) is working properly.

The java version is the default one in the latest Raspbian (now Raspberry Pi OS):

Code: Select all

openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Raspbian-1deb10u2)
OpenJDK Server VM (build 11.0.9.1+1-post-Raspbian-1deb10u2, mixed mode)
I've tested it with a standard FTDI USB cable (TTL-232R-3V3), but I suspect there would be a simpler method than that using the RPi's native GPIO port.

Thank you once again!
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

Nice to hear that it is working! 8-)
... I suspect there would be a simpler method than that using the RPi's native GPIO port.
There sits a lot of logic in the JP12serial library, logic that strictly speaking should not be there, but in the main program. (See the sources.) Feel free to try, but it is hardly expected to be "simple". :wink:
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

Now that I have finally acquired a Raspbery Pi 4, I have been able to investigate why RMIR failed to find a Nevo C2 in Barf's tests. RMIR uses this JNI wrapper from com.codeminders to access the C/C++ HIDAPI library. The distribution for that wrapper includes 32-bit and 64-bit hidapi binaries for Windows, Linux and Mac OS X and the appropriate one of these is extracted by RMIR for its use, but it does not include one for Linux-arm needed by the RPi. Although RMIR uses the latest version of the wrapper, v1.1, that dates from 2012. The C/C++ HIDAPI library has moved on a lot since then and that wrapper is not compatible with the Linux-arm version of libhidapi.so that Barf installed separately on RPi.

That wrapper has been superseded by hid4java, which includes a Linux-arm binary in its distribution. I have produced, for my own testing, RMIR v2.14.1 which uses this new wrapper. It works well on my Windows 10 machine but still has problems on my Raspberry Pi. I have tested it with both an XSight Lite and a Nevo C2 and in both cases, on the RPi it finds the remotes but fails to open them. Here are extracts from rmaster.err with the XSight Lite on both machines:

Extract from rmaster.err on RPi 4:

Code: Select all

System Properties:
   java.version = 11.0.9.1
   java.vendor = Raspbian
   os.name = Linux
   os.arch = arm
   java.home = /usr/lib/jvm/java-11-openjdk-armhf
   java.class.path = /home/pi/Documents/RemoteMaster/RMIR2.14.1/RemoteMaster.jar
...
LibraryLoader: Attempting to load 'hidapi' from '/home/pi/Documents/RemoteMaster/RMIR2.14.1/Linux-arm/libhidapi.so'...
LibraryLoader: Loaded 'hidapi' successfully from '/home/pi/Documents/RemoteMaster/RMIR2.14.1/Linux-arm/libhidapi.so'
    CommHID version 2.0
...
Testing interface: CommHID
Remote found: Manufacturer = null, Product = null, Product ID = 8008
Open found device failed
Failed to open remote
Corresponding extracts from Windows 10:

Code: Select all

System Properties:
   java.version = 14.0.2
   java.vendor = Oracle Corporation
   os.name = Windows 10
   os.arch = amd64
   java.home = C:\Program Files\Java\jdk-14.0.2
   java.class.path = RemoteMaster.jar
...
LibraryLoader: Attempting to load 'hidapi' from 'C:\RemoteMaster2.14.1\Windows-amd64\hidapi.dll'...
LibraryLoader: Loaded 'hidapi' successfully from 'C:\RemoteMaster2.14.1\Windows-amd64\hidapi.dll'
    CommHID version 2.0
...
Testing interface: CommHID
Remote found: Manufacturer = Maxim, Product = DIGITAL LITE   , Product ID = 8008
Open found device succeeded
You will see that the implementation of hidapi on the RPi is clearly incomplete, as it gives null values for the Manufacturer and Product values for the remote. Those are text values for information only, so this should have no effect on its ability to open a device, but perhaps it is indicative of incompletenesses elsewhere.

I would welcome any suggestions on what might be causing this failure to open a remote that it has already identified, or anything else that I might try.
Graham
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

It may be a permission problem; try to run as root. (Of course only for debugging, not for deployment.)
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

Barf wrote:It may be a permission problem; try to run as root. (Of course only for debugging, not for deployment.)
Yes, that's done it. So how do I deal with this when not running as root?
Graham
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

A further problem. When I wrote that running as root had done it, I had only tried the XSight Lite. With the Nevo C2 the remote is opened, identified correctly as Nevo C2, but it fails on the check to see if an upgrade is needed, with rmaster.err giving the line "Read versions from remote failed to initiate". Java created an error log, here is an extract:

Code: Select all

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x8f8b5348, pid=1228, tid=1317
#
# JRE version: OpenJDK Runtime Environment (11.0.9.1+1) (build 11.0.9.1+1-post-Raspbian-1deb10u2)
# Java VM: OpenJDK Server VM (11.0.9.1+1-post-Raspbian-1deb10u2, mixed mode, g1 gc, linux-)
# Problematic frame:
# C  [libusb-1.0.so.0+0x5348]  libusb_exit+0xa4
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   Unknown
# The crash happened outside the Java Virtual Machine in native code.
No such problem occurs in Windows. I haven't yet tried this RMIR version in Linux, but I will do so.

Edit: No such problem in 64-bit Ubuntu either.
Graham
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

mathdon wrote:
Barf wrote:It may be a permission problem; try to run as root. (Of course only for debugging, not for deployment.)
Yes, that's done it. So how do I deal with this when not running as root?
You have installed linux_xsight.rules, right? And made yourself a member of the dialout group? Iff yes, try to debug the workings of udevd, i.e. compare the files created when you plug in the xsight to the RPi with the files created by your Ubunto system.
Java created an error log, here is an extract:
libusb goes bellyup, sigh... :cry: You may try the raspian forum
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

Barf wrote:You have installed linux_xsight.rules, right?
Sorry, my mistake :oops: , despite your warning to do so that setup.sh shows at the end. It is also explained in my own RMIR Announcements that this may be necessary, so I am guilty of not even following my own instructions :oops: :oops: :oops: . I have now done so and that has fixed the opening problem, so am left with just the libusb problem.
Graham
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

The libusb problem seems to arise after RMIR has aborted the download. The abort occurs when RMIR fails to read an incoming data packet from the remote, which appears to be due to a timing issue. I don't fully understand what is going on. I added some diagnostic print-outs to the rmaster.err file and found that a side effect was that it ran past the original failure point, only to fail again at a later stage, which has convinced me that the problems are solvable. By adding some further delays, I have managed to get one successful download from the Nevo C2 but I don't like what I have done and at present it doesn't seem consistently reliable. I shall continue to work on it.
Graham
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

Since libusb dies in C code due to a segmentation error, my gut feeling is that it is a (possibly seldomly triggered) bug in said library. Another possibily is that RMIR somehow uses it incorrectly (but it is still nasty to die from a SIGSEGV).
Post Reply