JP1 Remotes Forum Index JP1 Remotes


FAQFAQ SearchSearch 7 days of topics7 Days MemberlistMemberlist UsergroupsUsergroups RegisterRegister
ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

How to use DecodeIR standalone?

 
Post new topic   Reply to topic    JP1 Remotes Forum Index -> JP1 - Software
View previous topic :: View next topic  
Author Message
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sun Sep 16, 2012 4:15 am    Post subject: How to use DecodeIR standalone? Reply with quote

I am working on an Arduino-based protocol analyzer widget that uses DecodeIR to interpret the raw codes.

Hence, I am looking for a way to, on the command line, enter
Code:
decodeir -28394 +8950 -4450 +600 -500 +600 -550 +550 -1650 +600 -500 +550 -550 +600 -550 +600 -500 +550 -600 +550 -1650 +550 -1650 +600 -550 +550 -550 +600 -1600 +600 -1650 +600 -1650 +600 -1600 +550 -600 +550 -550 +600 -1650 +550 -550 +600 -1600 +600 -550 +600 -500 +550 -550 +600 -1600 +600 -1650 +600 -500 +600 -1650 +600 -500 +600 -1650 +600 -1650 +550 -1650 +550

and get back
Code:
Protocol=NEC  Device=4.243  OBC=20
   IRP form:   {0.0k,msb}<-575u|600u,-500u>(<1:-1|1:-2|1:-3|1:-4>(8945u,-4453u,A:64,552u)){A=$0800A0AA0880A22A}
   Single:   +8950 -4450 +600 -500 +600 -550 +550 -1650 +600 -500 +550 -550 +600 -550 +600 -500 +550 -600 +550 -1650 +550 -1650 +600 -550 +550 -550 +600 -1600 +600 -1650 +600 -1650 +600 -1600 +550 -600 +550 -550 +600 -1650 +550 -550 +600 -1600 +600 -550 +600 -500 +550 -550 +600 -1600 +600 -1650 +600 -500 +600 -1650 +600 -500 +600 -1650 +600 -1650 +550 -1650 +550 -0

I believe this should be trivial using a tiny C program that uses libdecodeir.so but unfortunately I can't seem to find any C sample code.

Can you please point me toward the correct solution?
Also, it should be possible to call the library from Python using ctypes, if anyone knows how to do that, I'd be very much interested too.

Thanks!
Back to top
View user's profile Send private message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1415
Location: Munich, Germany

                    
PostPosted: Sun Sep 16, 2012 6:02 am    Post subject: Reply with quote

Hi probono,

Here is what you are looking for. Possibly with the exception that it takes the CCF form as input, not the raw form you are using, modifying it should not present any problem for you. (Note that no-one of the replies understand (or care) for the content of the posting -- what a nice forum Crying or Very sad )

You can also use IrpMaster from the command line,
Code:
$ irpmaster --analyze --decodeir --ccf 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 06A4 015B 0057 0016 0E6C
protocol = NEC1, device = 12, subdevice = 34, obc = 56
AnalyzeIR: {38.4k,573,msb}<1,-1|1,-3>(16,-8,A:32,1,^109m,(16,-4,1,^108m)+){A=0x30441ce3}

(The present version supports only CCF and UEI learned formats, the upcoming 0.2.2 also raw format:)
Code:
java -jar dist/IrpMaster.jar  --decodeir --ccf  +9024 -4512 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -44268 +9024 -2256 +564 -96156
protocol = NEC1, device = 12, subdevice = 34, obc = 56
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sun Sep 16, 2012 6:12 am    Post subject: Reply with quote

Hi Barf, thanks a lot. Unfortunately I have exactly zero Java skills, so I have to wait until you release your next version that supports raw decoding.
Back to top
View user's profile Send private message
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sun Sep 16, 2012 6:17 am    Post subject: Reply with quote

Talking about IrpMaster, I would be very interested in a server-side version of it. Do you know how to do this? Running "java -jar IrpMaster.jar ... " on the server is slow, I am sure there must be a better way?
Back to top
View user's profile Send private message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1415
Location: Munich, Germany

                    
PostPosted: Sun Sep 16, 2012 9:13 am    Post subject: Reply with quote

probono wrote:
... Unfortunately I have exactly zero Java skills, so I have to wait until you release your next version that supports raw decoding.

The first part talked about a main routine in C++, so I do not understand that sentence as it stands.

Quote:
Talking about IrpMaster, I would be very interested in a server-side version of it.
IrpMaster is first of all a library will reasonably well defined and documented API. That means that you can just "link" with it, see the API example in the documentation and the doc directory. At least as long as you write your program in Java! Writing an "IrpMaster server" would thus essentially be a matter of a few hours for an experienced Java programmer. Since I do not have a particular use case, I do not have it on my TODO-list.But feel free to try to persuade me Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sun Sep 16, 2012 9:44 am    Post subject: Reply with quote

That's probably because I'm a python guy ,-)

About the server, I think it could be very useful to build kind of a wiki for IR codes. People could upload their detected raw codes, they would be decoded and the clean version of the IR code would be displayed. This would also be integrated with a devices database. This way we could build the world's largest IR code database that would grow better and larger than any commercial database.

We would make it very easy to use: no software installation, automatic conversion of the codes into the most common formats. This coupled with very inexpensive and common devices, such as Arduino, should allow for rapid adoption.

One day, we could even design a fully open-source infrared remote control. What do you think?
Back to top
View user's profile Send private message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1415
Location: Munich, Germany

                    
PostPosted: Sun Sep 16, 2012 3:43 pm    Post subject: Reply with quote

probono wrote:
What do you think?


I have written down my thoughts here, which may also be a more appropriate place to take the discussion. After all, this is the forum for getting the maximum out out UEI remotes.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sun May 26, 2013 2:03 pm    Post subject: Reply with quote

For my own reference, this is how it works:

Code:
Generate signals

ubuntu-gnome@ubuntu-gnome:~/Desktop$ java -jar '/home/ubuntu-gnome/Downloads/IrMaster-bin/lib/IrpMaster.jar' -c /home/ubuntu-gnome/Downloads/IrMaster-bin/IrpProtocols.ini -u -r -n NEC1 0 191 2
Device Code: 0.191 Function: 2
+9024 -4512 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -1692 +564 -43992
+9024 -2256 +564 -97572
00 00 2F 00 D0 06 11 A0 08 D0 01 1A 01 1A 01 1A 03 4E 01 1A 55 EC 11 A0 04 68 01 1A BE 92 22 01 11 11 11 12 22 22 21 21 21 11 11 12 12 22 22 23 82 45

Decode signals - NEED IrpMaster 0.2.2 WHICH IS INCLUDED IN IrMaster 0.3.1 BINARIES FOR THIS TO WORK!!!

ubuntu-gnome@ubuntu-gnome:~/Desktop$ java -jar IrpMaster.jar  --decodeir --ccf  +9024 -4512 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -1692 +564 -564 +564 -564 +564 -564 +564 -1692 +564 -1692 +564 -44268 +9024 -2256 +564 -96156
protocol = NEC1, device = 12, subdevice = 34, obc = 56
Back to top
View user's profile Send private message
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sat Jun 01, 2013 11:11 am    Post subject: Reply with quote

And here is my tiny Python wrapper that collects the raw data from the Arduino and decodes it:

Code:
#! /usr/bin/env python

import os, sys, serial, select

port = "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0"
here = os.path.abspath(os.path.dirname(__file__))

# This is important, otherwise we get no decodes
os.environ['LD_LIBRARY_PATH'] = here + "/IrMaster-bin-0.3.1/Linux-i386/"

class Arduino():
    def run(self, baud=9600):
        try:
            self.ser = serial.Serial(port, baud, timeout=1)
        except:
            print "Could not open the serial port " + port
            sys.exit(1)
        self.ser.flushInput()
        while True :
            inp, outp, err = select.select([sys.stdin, self.ser], [], [], .2)
            if self.ser in inp :
                line = self.ser.readline().strip()
                if("+" in line):
                    command = here + "/jre/bin/java -jar " + here + \
                    "/IrMaster-bin-0.3.1/lib/IrpMaster.jar --decodeir --ccf " + \
                    line + " -43992"
                    # print command
                    os.system(command)
                   
arduino = Arduino()
arduino.run()

If only I could get rid of all the Java overhead just to call that c++ library...
Back to top
View user's profile Send private message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1415
Location: Munich, Germany

                    
PostPosted: Sun Jun 02, 2013 11:27 am    Post subject: Reply with quote

Hi probono,

congrats to your latest achievements!

Quote:
If only I could get rid of all the Java overhead just to call that c++ library...

Agreed, it is not sound to call a Java program, firing up the JVM, just to invoke a C++ shared library. But In my first posting, second in the thread, I gave you (in the link) a C++-program that did almost exactly what you asked for, as expressed in the thread title. The only thing you need to do is the fairly trivial conversion from the Pronto type input to raw inputs. That should be quite simple with your programming knowledge. The other direction would be considerably harder.

It should also be possible to call shared libraries directly from Python. I just entered "shared libraries with python" in Google, and got interesting hits.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Sat Jun 08, 2013 6:41 am    Post subject: Reply with quote

Thanks Barf. In our link to the C++-program the first thing I had trouble with is the Java stuff in the Makefile. I can't even get this to compile, as it always complains about some JNI stuff I have no real clue about...
Back to top
View user's profile Send private message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1415
Location: Munich, Germany

                    
PostPosted: Sat Jun 08, 2013 7:08 am    Post subject: Reply with quote

The "Java stuff" is DecodeIR's JNI connection, which we do not need here. You can just comment out/remove everything offending, like the include and all function starting with Java_com_hifiremote_decodeir. Possibly easier, in particular if you are not that familiar with C syntax, would be to install a JDK, Java Developer Kit, after which it should compile.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probono



Joined: 12 Aug 2012
Posts: 48

                    
PostPosted: Mon Jun 10, 2013 4:48 pm    Post subject: Reply with quote

Thanks Barf, removing everything related to Java and Windows indeed did the trick for me. I now have a tiny Linux decodeir executable. If anyone else is interested, I have uploaded the modified source to https://github.com/probonopd/decodeir
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic       JP1 Remotes Forum Index -> JP1 - Software All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

Powered by phpBB © 2001, 2005 phpBB Group
Top 7 Advantages of Playing Online Slots The Evolution of Remote Control