Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: WinLIRC as a channel changer

  1. #1
    I was looking for a simple and inexpensive way to make GBPVR change channels on my Starchoice satellite box. After some fooling around I managed to get this working.

    You will need WinLIRC http://winlirc.sourceforge.net/. There are instructions there on installation, configuration and how to make a simple $5 IR blaster that plugs into your serial port. You will need the file "transmit.exe" which unfortunately they left out of the latest v6.5. It can be found in some older archives such as 6.4 at http://cmail.info.kuzbass.net/~nav/

    The hard part is getting the IR codes for your tuner. WinLIRC has a learning feature (which requires additional hardware) but I found it's not that accurate at capturing the IR timings. I ended *up using a scope to measure the IR timings but now they are dead on. If you are lucky you can find what you need for your tuner - I can post my WinLIRC.RC config file which works for the Starchoice box if that helps somebody.

    I wrote a simple jscript program which calls transmit.exe to send the IR codes. You will have to put a copy of transmit.exe in \windows\system32. You will also have to have WinLIRC running, setting it up in you windows startup is probably a good idea so its running after a reboot.

    /////////////////////////////////////////////////////////////////////////////
    var cmdline;

    var WshShell = new ActiveXObject("WScript.Shell"

    objArgs = WScript.Arguments;

    // channel changer script for GBPVR
    // r heslip jan 1 2005
    //
    // executes WinLIRC "transmit.exe" three times to send the three digits
    // usage:
    // channel <remote> <channel> <repeats> <delay>
    // <remote> is the remote name as defined in winlirc.rc
    // <channel> is the three digit channel number
    // <repeats> is a repeat count passed to transmit.exe
    // <delay> is the delay in milliseconds to wait before transmitting again

    cmdline=new String ("transmit "

    cmdline=cmdline + objArgs(0)+ " " + objArgs(1).substr(0,1) +" " + objArgs(2);


    //WScript.Echo(cmdline); // helps with debugging !

    var oExec = WshShell.Exec(cmdline);

    while (oExec.Status == 0)
    {
    * * WScript.Sleep(10);
    }

    WScript.Sleep(objArgs(3));

    cmdline="transmit ";
    cmdline=cmdline + objArgs(0)+ " " + objArgs(1).substr(1,1) +" " + objArgs(2);

    // WScript.Echo(cmdline);

    var oExec = WshShell.Exec(cmdline);

    while (oExec.Status == 0)
    {
    * * WScript.Sleep(10);
    }

    WScript.Sleep(objArgs(3));

    cmdline="transmit ";
    cmdline=cmdline + objArgs(0)+ " " + objArgs(1).substr(2,1) +" " + objArgs(2);

    // WScript.Echo(cmdline);

    var oExec = WshShell.Exec(cmdline);

    while (oExec.Status == 0)
    {
    * * WScript.Sleep(10);
    }
    /////////////////////////////////////////////////////////////////

    GBPVR must pass the script 4 parameters - the name of the remote as configured in WinLIRC (in my case its "star&quot, the 3 digit channel number, an IR repeat count, and the delay in milliseconds between IR commands. I use a repeat of 1 and a delay of 1000ms - you may have to change this for your tuner.

    Configure GBPVR for an external .exe channel changer. The executable is windows script host:

    \WINDOWS\system32\wscript.exe

    The parameter string in my case is:

    "\Program Files\devnz\gbpvr\Winlirc PVR files\channel.js" star {channel} 1 1000

    The quotes around the script path are required. I installed the WinLIRC stuff in a subdir of GBPVR as you can see. Check the zero pad and 3 digit channel number boxes. If you have a 2 digit tuner, take out the last block that calls transmit.exe in the script.

    Its possible you might need the latest windows scripting host (5.6 ?) to make this work but it works fine on my XP Pro SP1 installation as is.

    WinLIRC seems to suck up a lot of CPU when its transmitting. On a Duron 900mhz box GBPVR would sometimes go back to the main menu when changing channels in Live TV, but it changed channels for recordings properly. On a P4 1.7ghz there is no problem.

    Hope this helps somebody.

    Rich

  2. #2
    Join Date
    Dec 2004
    Location
    New Jersey, US
    Posts
    300
    Can we get this posted somewhere that all new users can find this. - or at least somewhere prominent on wiki.

    I'm all setup but if I could avoided the cost of the usb-uirt device i would have.

    Nice work.

  3. #3
    For the sake of completeness, here is the WinLIRC config file I'm using for the Starchoice 301 receiver (made by Motorola)

    Rich


    #
    #
    # WinLIRC 0.6.5 (LIRC 0.6.1pre3) on Sun Nov 14 18:09:07 2004
    #
    # contributed by R Heslip
    #
    # brand: Starchoice satellite receiver (Motorola)
    # model: 301
    # supported devices: very basic channel changer
    #
    # note: most of the numbers below are timings in microseconds as measured on the remote
    # this codeset is almost identical in timing to the original remote
    # be careful with "gap" - if its shorter than the sum of header + all the bits
    # + ptrail, winLIRC 6.5 crashes very ungracefully !
    #

    begin remote

    name star
    bits 12
    flags SPACE_ENC
    eps 25
    aeps 100

    header 5600 2000
    one 1000 2900
    zero 1050 950
    ptrail 1000
    gap 60854
    toggle_bit 0
    min_repeat 2
    frequency 38000


    begin codes
    1 0x0000000000000F04
    2 0x0000000000000886
    3 0x000000000000048C
    4 0x0000000000000E83
    5 0x000000000000098B
    6 0x0000000000000D8D
    7 0x000000000000050B
    8 0x0000000000000901
    9 0x0000000000000708
    0 0x0000000000000246
    end codes

    end remote

  4. #4
    Join Date
    Mar 2005
    Location
    Nova Scotia
    Posts
    227
    Just wondering if any one else has managed to implement a method to change channels on an external device i.e. a cable box or Satellite receiver from within GB-PVR.

    I purchased a cheap serial port IR transceiver at a local discount retailer (JetEye PC, model ESI-9680, readily available on ebay or other sources).

    The ESI-9680 unit works without modification when hooked up to my PC. Checked this using the serial port watcher program, http://www.geocities.com/CapeCanaver...emotectrl.html to view data on the serial port.

    I am trying to control an older Bell ExpressVu 2700 Satellite receiver. I used a LIRC config file for another ExpressVu model 3100 and it worked fine for the 2700.
    http://lirc.sourceforge.net/remotes/expressvu/ Note: many other remote control config files are available on this site.

    Using WinLIRC in manual mode I can control the satellite receiver, turn it on/off and change channels.

    I am not a programmer and havenít written any code since 1993 and then it was in assembly language. So I wouldn't know an error if I saw one in windows scripting language. The channel.js script listed above has some html codes inserted in place of quotes and less, greater than symbols due to the conversion of the text to html display methods of this forum site.
    After trying to remove these inserted html codes I still get run errors for this script file.

    Does any one have a working script or alternative that calls WinLIRC transmit.exe from within GB-PRV.

    Regards,
    Richard

  5. #5
    Join Date
    Mar 2005
    Location
    Nova Scotia
    Posts
    227
    I finally got the script to work, after fixing the format changes. It is great to have GB-PVR switch channels on the satellite box....

    I'll be posting all my setup steps here soon to help others with an ExpressVu 2700/3100 receiver and Jeteye IR module.
    Regards,
    Richard

  6. #6
    Join Date
    Mar 2005
    Location
    Nova Scotia
    Posts
    227
    I think it more appropriate to post this under the WINLIRC thread as opposed to the external channel changer broken thread, as it is apparent that the .exe channel changer works, and my problem rests with WinLIRC.

    Here is what I have learnt over the past few days. Thanks to all who have responded with similar scripts/apps to test out similar functionality. All have indicated the same issue! Which I am getting too below.

    I have written a simplified NT script file (channel.cmd) that takes in the {channel} argument from the .exe channel changer, and passes the channel numbers to the WINLIRC command line IR transmit.exe executable.

    The script file also logs the passed channel numbers into a text file c:\input.txt in order to check that correct channel numbers are being passed.

    Results:
    From the GB-PVR TV guide I can select a TV channel to watch, channel changer calls the script file which parses the 3 digit channel number into 3 seperate digits, and then calls transmit.exe. The correct IR commands are sent and the external satellite box changes to the selected channel. As evident from the changed contents of input.txt file and the satellite box switching channels.

    From a command window I can run channel.cmd followed by the channel number, whereby the transmit.exe executable is called and the external satellite box changes to the selected channel.

    However when in recording mode for any selected ďto be recordedĒ TV show channel, at the correct time, the channel.cmd script is run, but transmit.exe executable dosenít run. Therefore the recording starts but the external satellite box channel remains at the original setting. The input.txt file logs the correct channel number so the channel.cmd script is running but transmit.exe is not being called. The same situation exists when in instant record mode.



    Does any one have any idea why for sometimes a batch called file will run but at other times it would not? Any other suggestions or altarnatives to a serial port IR blaster would be greatly appreciated.

    System
    I am running this on a Toshiba Tecra XP Pro laptop with SP2 installed.
    No TV in encoder card installed as this is my testing machine. Easier to move around than my P3 desktop which will be the final system when my Nvidia MX440 TV out card arrives.
    I have added the directories used to my PATH statement and ensured that the .cmd extension is included in the PATHEXT.

    Please see below for the channel.cmd script file

    ///////////////////////////////////////

    @echo off
    REM .exe channel changer send out the 3 digit channel number as one number
    rem i.e {345}
    rem
    rem However TRANSMIT.exe sends out the remote codes serially
    rem
    rem usage: transmit remotename codename #times to repeat IR signal
    rem
    REM Need to pass a string of 3 numbers to TRANSMIT i.e 345
    rem
    rem Therefore need to parse the 3 digit channel# 345 into three arguments
    rem for example:
    rem
    rem transmit 3100 3 1
    rem transmit 3100 4 1
    rem transmit 3100 5 1
    rem
    rem make it easy and hard code the remotename = 3100
    rem make it easy and hard code the repeat = 1


    rem Need to take in the {channel} as %1 then parse it into 3 digits

    SET CHANNEL=%1


    call C:\WINLIRC\transmit 3100 %CHANNEL:~0,1% 4
    rem copy 1st digit of channel # into input.txt file for debug purpose
    echo 3100 %CHANNEL:~0,1% 4 >> C:\INPUT.TXT
    SLEEP 1

    call C:\WINLIRC\transmit 3100 %CHANNEL:~1,1% 4
    rem copy 2nd digit of channel # into input.txt file for debug purpose
    echo 3100 %CHANNEL:~1,1% 4 >> C:\INPUT.TXT
    SLEEP 1

    call C:\WINLIRC\transmit 3100 %CHANNEL:~2,1% 4
    rem copy 3rd digit of channel # into input.txt file for debug purpose
    echo 3100 %CHANNEL:~2,1% 4 >> C:\INPUT.TXT
    SLEEP 1


    EXIT

    /////////////////////////////////////////////////////////

  7. #7
    Join Date
    Nov 2003
    Location
    NextPVR HQ, Wellington, New Zealand
    Posts
    76,029
    Transmit.exe is trying to use the clipboard to send data to WinLIRC. Since the recording service is not running as a process on the same desktop session as WinLIRC, this type of communication is not possible.

    Below is the source code to transmit.exe
    Code:
    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)+1;
    		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;
    }
    You'll need to find a replacement for transmit.exe that does this a different way.

    This is not a bug in GB-PVR.

  8. #8
    Sub

    Your explanation makes sense. It did work though on .2313 and .9010. I reinstalled with XP Home SP2 somewhere in there though and thats probably what broke it.

    WinLIRC is supposed to listen for requests on a specific socket if I remember correctly - you can change channels using a different machine if you want. I would think using that mechanism as opposed to the clipboard should make it functional. I have no idea how to code it tho !

    Rich

  9. #9
    Join Date
    Nov 2003
    Location
    NextPVR HQ, Wellington, New Zealand
    Posts
    76,029
    Your explanation makes sense. It did work though on .2313 and .9010. I reinstalled with XP Home SP2 somewhere in there though and thats probably what broke it.
    As you can see from dneprrider's tests and description above, GB-PVR is still living up to it's end of the bargain. GB-PVR is executing the configured executeable and passing the channel number correctly.

    I dont think it will work, but you could try: In the Control Panel -> Administrative Tools -> Services -> GB-PVR Recording Service, try enabling the 'interact with desktop' setting.

    WinLIRC is supposed to listen for requests on a specific socket if I remember correctly - you can change channels using a different machine if you want. I would think using that mechanism as opposed to the clipboard should make it functional. I have no idea how to code it tho !
    I agree, but sorry, I cant help you there. I'm busy with my own things.

  10. #10
    Join Date
    Mar 2005
    Location
    Nova Scotia
    Posts
    227
    I have enlisted a friend of mine to code a small executable that takes the recording service arguments; and passes the arguments to WinLIRCís TCP/IP server port. This method eliminates the problem of trying to pass arguments between windows sessions.

    I believe this to be a better solution to extending WinLIRC usefulness with GB-PVR.

    This will allow the recording service to control any WinLIRC compatible remote anywhere using TCP.


    Iíll post the code & executable when it has been fully debugged and working.



    Quote Originally Posted by sub
    As you can see from dneprrider's tests and description above, GB-PVR is still living up to it's end of the bargain. GB-PVR is executing the configured executeable and passing the channel number correctly.

    I dont think it will work, but you could try: In the Control Panel -> Administrative Tools -> Services -> GB-PVR Recording Service, try enabling the 'interact with desktop' setting.


    I agree, but sorry, I cant help you there. I'm busy with my own things.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •