Skip to main content
Topic: Hercules + WinLIRC AiO (Read 6726 times) previous topic - next topic

Hercules + WinLIRC AiO

I encapsulated the serial port in my application following OOP design (.NET), now I can start playing with the nice stuff, and maybe graphics.

Re: Hercules + WinLIRC AiO

Reply #1
Mockup  of how it's going to look.   :) )

Re: Hercules + WinLIRC AiO

Reply #2
What are you using, c# ? :)
Btw, if you wanted, you could use the irtoy winlirc plugin and use that to get the data. It exports the raw pulse/space information. Would make development easier for you !

Code looks something like this

Quote
while(hw->data_ready()) {

   data = hw->readdata(0);

   if(data&PULSE_BIT) {
      printf("PULSE %in",data&PULSE_MASK);
   }
   else {
      printf("SPACE %in",data&PULSE_MASK);
   }
}

Obviously that'll work for other receivers too not just the IRToy one :) I've got a command line prog which does this, but not released it yet.

Re: Hercules + WinLIRC AiO

Reply #3
You can also take a look at: http://www.swordspider.com/IRToyLogicAnalyzer.zip (source and binary in same zip)

It's what I've been working on today to test decoding of the Pioneer protocol. It's semidecently prepared to add more protocols.
Written in C# and XAML for what it's worth, ugly coding yes but well, it's not a work thing :P

It should decode NEC2 and Pioneer out of the box if you happen to have a remote of that kind.

Requires .NET Framework 3.5 (might be SP1) so no luck for you MAC/*nix guys I'm afraid, but it's what I work with so it's what I know.

The bar below the pulses changes color depending on which event trigger the bytes were read, helps isolate issues with incomplete frames (for some reason I don't seem to get the ending 0xFF 0xFF with my remote which is why I resorted to sampling for a certain amount of time).
Obligatory screenshot:

Re: Hercules + WinLIRC AiO

Reply #4
@dukey
If you are talking about importing the IR Toy plugin .dll, that would be great. The other option would be to use the command line version of WinLIRC.

@Shadowsoul
Thanks, I'll take a look at the code, but you must admit my first run of the "IR signal graphing module" shows some promise.    :)  )

I'm using C#, isn't that what everyone uses?!    :)

EDIT:
Shadowsoul, you are using .NET 4.0, is there something in your code that requires the new version?

VS 2010 loading time is offensive in my PC, and 4.0 is too big considering I can do the same with 3.5.

Re: Hercules + WinLIRC AiO

Reply #5
Great looking apps! If you want to contribute one to open source please let me know, I can provide SVN access.

Quote
I don't seem to get the ending 0xFF 0xFF with my remote

That concerns me (possible bug?). The final 0xff 0xff represents about 1.7seconds of no IR pulse, is it possible the serial port routine times out before the 0xff 0xff terminator command is sent?
Got a question? Please ask in the forum for the fastest answers.

Re: Hercules + WinLIRC AiO

Reply #6
[quote author="liyin"]
@Shadowsoul
Thanks, I'll take a look at the code, but you must admit my first run of the "IR signal graphing module" shows some promise.    :)  )

EDIT:
Shadowsoul, you are using .NET 4.0, is there something in your code that requires the new version?

VS 2010 loading time is offensive in my PC, and 4.0 is too big considering I can do the same with 3.5.
[/quote]

Hehe, yeah, I just posted it to show how I did it, multiple chefs sometimes come up with a smoother solution. You probably have a way nicer way of drawing the waveform than me, setting widths of graphical elements to imitate drawing is...somewhat ugly :)

Forgot VS2010 sets it to .NET4.0 by default, changed it now.
Apparently the only thing I used from 4.0 was StringBuilder.Clear and Debug.WriteLine(formatstring, params), so it was somewhat quick to fix :)


[quote author="ian"]
That concerns me (possible bug?). The final 0xff 0xff represents about 1.7seconds of no IR pulse, is it possible the serial port routine times out before the 0xff 0xff terminator command is sent?
[/quote]

I have modified the code so it also records how many milliseconds have elapsed when the event for datareceived is raised, it does not look like I get anything at the 1.7 second mark no matter what I do.

When I tidy my app up a bit I can "release" it to the SVN, at the moment it's a bit specific for my needs with the Pioneer stuff so :P

Re: Hercules + WinLIRC AiO

Reply #7
Can you please paste the output from a IRsample capture from a terminal program the display HEX?

I use Herculese, but you need to force it to go to HEX, then set, unset, and reset the 'nvt' feature to get it to show 0xff properly (not a great utility for this test, I know):
http://www.hw-group.com/products/hercules/index_en.html
Got a question? Please ask in the forum for the fastest answers.

Re: Hercules + WinLIRC AiO

Reply #8
This is from the RED-button on my blu-ray using the Hercules program in HEX-mode:
Code: [Select]
{01}{8F}{00}{C7}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{4A}{00}{19}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{18}{00}{19}{00}{17}{00}{1A}{00}{18}{00}{19}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{04}{A6}{01}{8F}{00}{C7}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{18}{00}{19}{00}{18}{00}{19}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{4A}{00}{19}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{18}{00}{19}{00}{49}{00}{1A}{FF}{FF}

And the GREEN- button as well:
Code: [Select]
{01}{90}{00}{C6}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{18}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{18}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{18}{00}{1A}{00}{18}{00}{19}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{18}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{04}{A6}{01}{90}{00}{C6}{00}{1A}{00}{49}{00}{1A}{00}{48}{00}{1B}{00}{48}{00}{1B}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{18}{00}{1A}{00}{18}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1B}{00}{16}{00}{1B}{00}{48}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{49}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1A}{00}{48}{00}{1A}{00}{17}{00}{1A}{00}{17}{00}{1A}{00}{48}{00}{1B}{FF}{FF}


The 0xFF 0xFF at the end arrive after the keypress, not sure if it's actually 1.7 seconds or faster but there is a definite delay. I think I get it in my program as well, need to do some debugging on that part to see if I can figure it out.

Also looking at this data I see why I have issues with my reading, I disregard the {00}  bytes and only could he bytes greater, which of course royally screws up the header which is greater than 255. Silly me, should've spotted the fact that 8000ish us ON requires 2 bytes to encode in number of 21us-pulses (800 / 21 = ~400).

Stupid stupid stupid of me :)

Re: Hercules + WinLIRC AiO

Reply #9
Glad it helped. We need an in-house utility like Herculese that is simpler for debugging stuff.

There is also a page on the wiki with the protocol and some examples:
http://dangerousprototypes.com/docs/USB ... e#Protocol

Quote
The first IR pulse starts a timer that measures length of the pulse. The length is returned as a 16bit count, high byte first. Multiply the raw 16bit timer value by 21.3333us to determine the actual length in microseconds.

The IR Toy continues to spit out measurements of each pulse and the blank space between. Sampling stops when there is no IR change for a full (0xffff) period of 1.7seconds. This will hopefully end during a blank period, but could be a pulse period if an IR jammer were in use. After a full period of no change the IR Toy 'sleeps' and won't send any more data until the beginning of the next IR pulse.
Got a question? Please ask in the forum for the fastest answers.

Re: Hercules + WinLIRC AiO

Reply #10
Updated the zip with a newer version that doesn't require .NET4 now.

Also fully supports the 3 Pioneer remotes I have, now I just need to figure out how to move the code from C# to either the Firmware (might not be the best idea due to the complexity) or to the LIRC-driver.

Re: Hercules + WinLIRC AiO

Reply #11
The UI is very nice.
Got a question? Please ask in the forum for the fastest answers.

Re: Hercules + WinLIRC AiO

Reply #12
Maybe nothing, but got this from AV:

Quote
C:...IRToyLogicAnalyzerIRToyLogicAnalyzerBusinessUtilitiesPioneerDecoder.cs
[DETECTION] Contains recognition pattern of the HTML/Rce.Gen HTML script virus

Re: Hercules + WinLIRC AiO

Reply #13
[quote author="liyin"]
Maybe nothing, but got this from AV:

Quote
C:...IRToyLogicAnalyzerIRToyLogicAnalyzerBusinessUtilitiesPioneerDecoder.cs
[DETECTION] Contains recognition pattern of the HTML/Rce.Gen HTML script virus
[/quote]

Can't find anything not visible in the source code editor in the file.
It probably reacted to one of the many many many long arrays of info for the Pronto HEX. Kind of unnecessary data perhaps but I wanted to be able to find out all the info about the button I press :P

Re: Hercules + WinLIRC AiO

Reply #14
My AV gives many false positives, but the previous version of the .cs didn't give a warning. It looks harmless.