Skip to main content
Topic: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin (Read 9441 times) previous topic - next topic

Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

I can send codes one by one using WinLIRC, but I want to automate six devices in several combinations and settings, so I was trying EventGhost as recommended.

==============================================================
When using EventGhost & the LIRC plugin & WinLIRC - I can receive IR OK, but transmit fails with the following message:

LIRC Client: Send Event: SEND_ONCE SE-RK310A power
LIRC Client: Received an erroneous response from the LIRC-server
Message data: ['unknown command: SEND_ONCE']

EventGhost has sucessufully used LIST to get remotes info.
Manual execution of commands LIST and VERSION execute without error.

Version info:
   EventGhost 0.3.7.r1462 - 1st
   + LIRC plugin v0.7.5
   + WinLIRC 0.86b OR + WinLIRC 0.87

==============================================================

When using EventGhost + USB IR Toy plugin, I can also receive IR commands OK, but Transmitting "R" gives the following error:

USB Infrared Toy: Transmit IR
Error sending IR code to IR Toy
Transmitting timed out


Note _ I am only sending an "R" as this is the only Code1 & 2 command I have "worked out" is valid so far.

Version info:
   EventGhost 0.3.7.r1462 - 1st
   + IR Toy plugin V.08.02

I have noted that this plugin is "far from perfect".
==============================================================

EDIT: I am aware of the range issue and am using a 39ohm resistor to increase my range form 15cm to 3 meters (for 5 of my six devices).

Does anyone have any suggestions how to progress?

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #1
Hi spanner - what IR Toy firmware are you using (v entered into a serial terminal)?
Got a question? Please ask in the forum for the fastest answers.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #2
Hi

I am using v107. I am resisting upgrading to v108 as I have had issues (ie killed device) with upgrading fw on other devices.....

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #3
It tells you the problem right there.

Quote
LIRC Client: Send Event: SEND_ONCE SE-RK310A power
LIRC Client: Received an erroneous response from the LIRC-server
Message data: ['unknown command: SEND_ONCE']

Lirc and winlirc have slightly different protocols for transmitting. The problem is eventghost doesn't support transmitting with winlirc.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #4
I'm not so sure this is an eventghost issue.

I took my first look at pyhon code in looking at the code by adding some debug "prints". I can see that the init process does establish a connection. And the list of remotes and codes for each remote is also successfully retrieved and displayed. 

I also manually sent some commands (list, version) to winlirc from eventghost, but commands like SEND_ONCE which appear in eventghost and in the lirc command reference do not seem to work. 

My stumbling through the winlirc code showed that the LIST & VERSION commands were explicitly coded, but I got a bit lost in the fall through condition that may/may not have handled more commands. So I am unsure whether these transmit type commands are actually supported in winlirc.

My second attempt using the IR Toy plugin also failed as noted in the original post.  My stumbling into the code is starting to make me think the transmit code is not yet working.  I am continuing to stumble a bit further with this, but really hoping to find someone with some knowledge of eventghost/python/these plugins to provide some guidance :)

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #5
I know the problem is eventghost. I am the winlirc developer !
You should be able to send fine directly with winlirc. However the range on the IR Toy is very very small, maybe 10cm. I think you might need to change one of the resistors on the board to make sending better, but you need to ask the other guys about that.

In order to send with winlirc, via tcp, you need to set a password in the registery. (But this is not documented anywhere). So you can see right away it's different. There is also another method which uses a copydata struct passed to the window of the program.

I am tempted to rewrite the WinLIRC server a bit to properly emulate all the LIRC commands, however I know if i do this I am going to get a flood of emails complaining i've broken the api. So I am a little reluctant to rewrite it, especially seeing as how winlirc has really been unchanged for something like 7-8 years.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #6
Hi & thanks for the info.

I can send OK directly from WinLIRC, and using a 39ohm resistor, I am getting a range of ~3 meters.

I can see the password code & registry locations, so I will try those.

Is there any more detail on the second "method which uses a copydata struct passed to the window of the program"?

Are you able to confirm that WinLIRC does not support SEND_ONCE etc?

thanks heaps for the help, it gives me confidence to move forward.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #7
Quote
Is there any more detail on the second "method which uses a copydata struct passed to the window of the program"?

The transmit.exe bundled with the latest winlirc uses the this method.

The source is essentially just this
Code: [Select]
#include <windows.h>
#include <stdio.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    LRESULT copyDataResult;
    HWND pOtherWnd = FindWindow(NULL, "WinLirc");
    if (pOtherWnd)
    {
        COPYDATASTRUCT cpd;
        cpd.dwData = 0;
        cpd.cbData = strlen(lpCmdLine);
        cpd.lpData = (void*)lpCmdLine;
        copyDataResult = SendMessage(pOtherWnd,WM_COPYDATA,(WPARAM)hInstance,(LPARAM)&cpd);
        // copyDataResult has value returned by other app
    }
    else
    {
        return 1;
    }
    return 0;
}

I know that winlirc doesn't support send once. But, you are welcome to change the source of winlirc yourself and add it. I'll probably want to merge that with the main code sometime in the future.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #8
Thanks to the help given, I can now transmit using EG & WinLIRC. There are a couple of key steps that are not highlighted - see steps 2 and 3 below.

The steps I used are listed in brief below.


I am also still keen to try the IRToy plugin with EventGhost for transmit.  The original post shows where I got up to. Does anyone have any ideas?
--------------------------------------------------------------------------------

Configuring EventGhost (EG) & WinLirc

Step 1. First get WinLirc running with the desired remote(s).

STEP 2 - Advice on executing WinLirc:
   (from C:Program FilesEventGhostpluginsLirc__init__.py)

## Script for handling (Win)Lirc events by jinxdone - 16th December 2007
###
###
### EventGhost plugin for receiving Lirc-style events written in python.
###
### This plugin has been made to work with WinLirc (http://winlirc.sourceforge.net/),
### though it should also work with any version of Lirc (http://www.lirc.org/).
###
### If you are using WinLirc I'd suggest setting it a higher priority than normal.
### It's also a good idea to autorun it from somewhere, for example from
### eventghost or automatically during windows startup etc.
###
### Example of launching winlirc with higher priority:
### cmd.exe /C "start /realtime /min /B /D C:winlirc C:winlircwinlirc.exe"


I used a batch file to fit my setup:

cd "C:Documents and SettingsbfDesktopsf current_ActiveDP IR ToyIR software & Infowinlirc-0.8.7WinLIRC"
cmd.exe /C "start /realtime /min /B /D . winlirc.exe"

3. Add the password registry entry: WinLIRC_password.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWARELIRC]
"password"="SEND_ONCE"
   See: http://winlirc.sourceforge.net/technicaldetails.html
   If EG is running when you add these registry keys, you may need to restart it.
4. Start WinLIRC (note advice at step 2) - and have it configured + remotes...
5. Do not have IRtoy plugin installed/active in EG.
6. In EG, Add plugin LIRC client (not WinLIRC!). Configure the plugin to meet your needs.
   I chose to "List remotes from the LIRC server" as this is extremely useful at step 8.
7. It receives by default and has default KB etc actions already defined (via other parts of std EG cfg).
For example: Power button on a remote - wants to close EG (because it was the active app?).
8. Create a folder under the "Context Folder" tree, Add a macro, then Add an Action - select LIRC send action.
   If you choose to "List remotes from the LIRC server" during the LIRC cfg then you will have the remotes + buttons available!
9. Continue adding macros & actions as desired.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #9
Thanks for the update, I'm glad you got it working. May I add this to the wiki (CC-BY-SA license)? I'm sure it will help a lot of other people trying to do the same.

Quote
I am tempted to rewrite the WinLIRC server a bit to properly emulate all the LIRC commands, however I know if i do this I am going to get a flood of emails complaining i've broken the api. So I am a little reluctant to rewrite it, especially seeing as how winlirc has really been unchanged for something like 7-8 years.

Maybe as an optional mode you can satisfy everyone.
Got a question? Please ask in the forum for the fastest answers.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #10
Yes, please add this to the Wiki using the necessary licence.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #11
Thanks, I added it here:
http://dangerousprototypes.com/docs/USB ... se_WinLIRC

Quote
I am also still keen to try the IRToy plugin with EventGhost for transmit.  The original post shows where I got up to. Does anyone have any ideas?

The IR Toy plugin is based on another plugin. It scales the IR Toy input to match the same resolution, which is a less than perfect solution (by far). It seems like the EventGhost decoder A)only takes 8bit data, not the IR toy 16bit, and B)doesn't process until the end of frame marker (depending on protocol?).

I'm not sure about the transmit error, I've only extensively tested receive.

v8 is a good upgrade, I highly recommend it. The IR Toy upgrade process is really safe, and I can reflash it for you if something goes wrong.
Got a question? Please ask in the forum for the fastest answers.

Re: Can't transmit with EventGhost - using either WinLIRC or USB IR Toy plugin

Reply #12
I've been debugging the server part of the winlirc code, and have found a few bugs. Anyway, see if you spot what's wrong here.

Quote
    {
        COPYDATASTRUCT cpd;
        cpd.dwData = 0;
        cpd.cbData = strlen(lpCmdLine);
        cpd.lpData = (void*)lpCmdLine;
        copyDataResult = SendMessage(pOtherWnd,WM_COPYDATA,(WPARAM)hInstance,(LPARAM)&cpd);
    }