Home AMX User Forum NetLinx Studio

Can't control an IR device via a Mio R2?

I have a directv box that I am unable to control via an R2. Let me explain:
I have an NI-3100 with all IR ports full, also an NXC-IRS, and an NXB-IRS4. The sat box in question is landed on the NXB-IRS4, which is addressed correctly, as I can see it in my device tree. I have programmed an 8400 to control this box, and it works fine, but when I try to control it with the R2, I get no control. Here is the related code for the R2:
DEFINE_DEVICE
RFGUEST418  		= 130:1:0  //418 Gateway in Guest1
DEFINE_VARIABLE
volatile integer nSatGuest [] = 
{
10,  //0
11,
12,
13,
14,
15,
16,
17,
18,
19,
21,  //enter
22,  //ch up
23,  //ch dn
24,  //vol up
25,  //vol dn
26,  //mute
31,  //menu  needs to be the # from the MIO R2.
32,  //up
33,  //down
34,  //left
35,  //right
36,  //select
37,  //exit
38,  //guide
39,   //info
40    //prev channel

}
BUTTON_EVENT[RFGUEST418,nSatGuest]

{
    PUSH:
    {
	local_var integer nBtnSat
	nBtnSat = GET_LAST(nSatGuest)
	SWITCH(nBtnSat)
	{
	    
	    CASE 1:
	    {
		PULSE[SAT_4,10]
	    }
	    CASE 2:
	    {
		PULSE[SAT_4,11]
	    }
	    CASE 3:
	    {
		PULSE[SAT_4,12]
	    }
	    CASE 4:
	    {
		PULSE[SAT_4,13]
	    }
	    CASE 5:
	    {
		PULSE[SAT_4,14]
	    }
	    CASE 6:
	    {
		PULSE[SAT_4,15]
	    }
	    CASE 7:
	    {
		PULSE[SAT_4,16]
	    }
	    CASE 8:
	    {
		PULSE[SAT_4,17]
	    }
	    CASE 9:
	    {
		PULSE[SAT_4,18]
	    }
	    CASE 10:
	    {
		PULSE[SAT_4,19]
	    }
	    CASE 11:
	    {
		PULSE[SAT_4,21]
	    }
	    CASE 12:
	    {
		PULSE[SAT_4,22]
	    }
	    CASE 13:
	    {
		PULSE[SAT_4,23]
	    }
	    CASE 14:
	    {
		TO[TV_GUEST1,24]  //TV Vol Up
	    }
	    CASE 15:
	    {
		TO[TV_GUEST1,25]  //TV Vol Down
	    }
	    CASE 16:
	    {
		TO[TV_GUEST1,26]  //TV Mute
	    }
	    CASE 17:  //Menu
	    {
		PULSE[SAT_4,44]
	    }
	    CASE 18:  //Up
	    {
		PULSE[SAT_4,45]
	    }
	    CASE 19:  //Down
	    {
		PULSE[SAT_4,46]
	    }
	    CASE 20:  //Left
	    {
		PULSE[SAT_4,47]
	    }
	    CASE 21:  //Right
	    {
		PULSE[SAT_4,48]
	    }
	    CASE 22:  //Select
	    {
		PULSE[SAT_4,49]
	    }
	    CASE 23:  //Exit
	    {
		PULSE[SAT_4,50]
	    }
	    CASE 24:  //Guide
	    {
		PULSE[SAT_4,56]
	    }
	    CASE 25:  //Info
	    {
		PULSE[SAT_4,65]
	    }
	}
    
    }
}

Basically, I can use the R2 to turn the tv in the room on (it is wired to the 3100), switch the autopatch switcher to the correct input, but then I get no control. I have used the "control a device" option under diagnostics, and it works - I can send the menu command and I see the box respond. I also can control the blu ray player from the R2, which is also connected to the NI. I would LOVE to move the IRs around, but I simply can't - I have EVERYTHING else working right now, just not the one sat box in one guest room! Help! It's gotta be something in my code!

Comments

  • vegastechvegastech Posts: 369
    Oh, and my sat_4 is declared as well:
    DEFINE_DEVICE
    SAT_4			= 199:1:0   //NXB-IRS4 
    
  • John NagyJohn Nagy Posts: 1,742
    Try pressing the first "source" button on the R2 (that's the upper left in the set of 6, just below the set of three at the top). I bet it works.

    Why?

    The R1 and R2 have a 40 command set FOR EACH OF THE SIX SOURCE BUTTONS. Button one activates commands 1-40, button 2 shifts the R1/R2 buttons up to send 41-80, etc.

    This is all documented in the R1/2/3 manuals.

    Turn on diagnostic PUSH display in NetLinx Studio and you'll see the actual button codes appear in the bottom green bar in NLStudio. If your code only knows 1-4, and it isn't in that mode, you'll get pushes you don't handle.

    To make the buttons work all the time regardless of the shift, you need your code to recognize 1, 41, 81. 121, 161, and 201 all to do the same thing. Etc.

    This is due to the thought by the designers that you'd want PLAY to mean something different based on which source you have selected, that the play itself would go to the right device because of the shift. This might be good for some, for us it is painful.

    Or of course, this may not be your problem at all. But probably is.
  • vegastech wrote: »
    I have used the "control a device" option under diagnostics, and it works - I can send the menu command and I see the box respond.

    Have you tried "Emulate a Device" to fake the pressing of R2 buttons? If it works there but not from the actual remote then John Nagy may be right about the cause. Need to watch the button presses in Notifications to see that the right channel code is being received. While you're at it, set up notifications to watch the IR port to see if it is being triggered.

    If Notifications shows that the right channel codes are being hit on the remote, but the IR port isn't firing then you probably do have a gremlin in your code. Put in debug statements (send_string 0:1:0) to watch in Diagnostics. I've seen at various times over the years, code that is syntactically correct that still doesn't work. Apparently due to unpredictable glitches in the compiler. Try moving the button event to another spot in the code. Try using a global variable instead of a local. Try adding extra lines of code. Try different things that shouldn't make a difference. They might fix it anyway. I say this because I've seen times in the past where inexplicable things were happening, and only by doing these types of things that you shouldn't have to do was I able to fix it.

    On the other hand, if you DO see that the IR port is being triggered, but the IR device is not being controlled, you may just need to use set_pulse_time. Or use CTON and CTOF with an SP send_command instead of PULSE.
  • vegastechvegastech Posts: 369
    Actually, that first source button IS my sat source, so I'm actually using exactly the buttons that I declared in my code. I hope. I guess I've got a gremlin somewhere...so is it safe for me to assume that the code I posted looks correct for what I'm trying to do, at least in the limited scope that I presented?
  • Just from reading it, without jumping in head first and fixing it myself, the code looks fine from what I can tell. You didn't really reply to any of my suggestions or questions, but I hope they help you figure it out.
  • vegastechvegastech Posts: 369
    Sorry J - I skipped to the bottom of the page when it refreshed and didn't look up! I tried the Emulate a Device dialog, but perhaps I'm not using it right - I added the address for a known working sat receiver, at 5003:1:0, and tried using the push button with the power code of 28, but nothing happened. Should I be trying this on the user interface, and not actually the device I want to control?
Sign In or Register to comment.