PDA

View Full Version : DirecTv HR-XX plugin



FearTheDentist
December 7th, 2009, 10:09 PM
Working on another serial plugin (sorry Rob :D ), this time for DirecTv HD receivers\DVRs.

I've got G5 talking to the unit, and can send simple commands no problem. 2 issues:

First- the responses from the unit are in hexadecimal- is there a way to tell G5t to convert this to ASCII? When I print (data) from a response from the receiver I get stuff like this: HR20 Data ð. How can "ð" be converted to a form that G5 or NR can use?

Second- a much bigger concern is how to write the script for direct channel input. For a direct channel command, the structure is:

[command byte][major channel hi][major channel lo][minor channel hi][minor channel lo]

So- to change to channel 276 the command is A60114FFFF.
A6=command byte, 01 14 = "276" in hexadecimal, FF FF= no minor channel (most channels do not have minor channels. I haven't figured out what they even are yet, possibly HD vs standard def?). If the hexadecimal for the channel is 2 chars only, then [major channel hi] is "00" eg change to channel 250 = A600FAFFFF.

So- G5 has to know that when a numerical keypress is entered on the remote that it has to "build" a command. My thought is that G5 should send the command when either 1) 4 digits have been entered; 2) less than 4 digits followed by "enter"; or 3) less than 4 digits are entered followed by a time out (or alternatively a time out could clear the command, maybe that could be a preference to be set by the user).

This is all fine and dandy, but I have only the vaguest notion of where to begin :(

Attached are my plugin so far and the serial protocol.

As usual your help is greatly appreciated!

Brian

Rob H
December 8th, 2009, 05:39 AM
For the first one you may want to take a look at the math.bytetohex() function, although Girder should be happy enough with the data in its original form.

For the second one, take a look at Build Channel Number Example.gml in the GML folder and also the underlying BuildString.lua in luascript\Classes

FearTheDentist
December 13th, 2009, 11:21 PM
OK- I've been fiddling around with this, and can use the channel that is built, but I don't think my approach is the best way.

From the Lua tutorial it looks like I should be able to see the channel I've built with something along the lines of:


print (Channel.String)

This seems to be incorrect, but I can't figure what to put in place of 'String'.

So- I went into BuildString.lua and added


MyChannnel=(unpack(arg))

such:


Event = function (self,Event,...)
self.Publisher:Event (Event,unpack (arg))

if Event == Events.Complete and self.EventString then
gir.TriggerEvent (self.EventString.. arg [1],18)
gir.TriggerEvent (self.EventString,18,arg [1])
end
print ('Build',Event,unpack (arg))
MyChannel=(unpack(arg)) <----HERE
end,


Now from the Lua console I can 'print (MyChannel)' and get the channel I built.

This works, but I don't think it's the best approach. What would you suggest?

Rob H
December 14th, 2009, 06:08 PM
You need to use the Subscribe() method of your BuildString object to add an event handler.

FearTheDentist
December 15th, 2009, 01:54 PM
Thanks for the info Rob. Unfortunately, this is me you're dealing with as opposed to a real programmer ;)
Would you mind being a little more specific? I'm just not sure where to start. Looking through the help files and other scripts, I think I need something along the lines of this bit from ActiveRFIDReceiver.lua (but adapted to BuildChannel of course):


OnReceiveData = function (self,Event)
local data = Event:GetData ()
self:Event (self.Events.RFIDTag,data)
-- print ('RFID: ',Event)
end,

But, so far none of my efforts have yielded anything..

Thanks!

Rob H
December 16th, 2009, 09:13 AM
Actually, you may not even need to use Subscribe() - you should be getting a couple of BuildString: events when the string is completed. May be easiest to deal with that in a GML instead.