LinuxMCE Forums

General => Installation issues => Topic started by: merkur2k on October 03, 2008, 06:52:00 am

Title: Control DirecTV receiver via serial
Post by: merkur2k on October 03, 2008, 06:52:00 am
I am working on switching to LMCE from my existing pure MythTV setup, but am not quite sure how to get LMCE to control my sat box. Currently MythTV calls an external perl script that simply accepts the channel number as its only option, and creates a data packet to send to the box over a connected serial cable. If the channel change succeeds, the script exits normally. If it fails, the script exits with an error.
The box is a RCA, model is D10-100 (yes, it is quite old. I passed on a free upgrade recently because I really like the serial control). I was unable to find an existing template for this system. I did poke around in the generic serial device, but it really doesnt make sense to me (and I am a programmer by trade). Is there some option I am overlooking in LMCE, or do I just set it up directly in MythTV like I have it in my current setup?
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 03, 2008, 01:50:04 pm
GSD's are very easy to set up, especially with regards to creating a new device template.

You may want to look at this to start:
http://wiki.linuxmce.org/index.php/Generic_Serial_Device

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 03, 2008, 03:12:17 pm
I had already read through that page, but it really didnt help me, perhaps because I know nothing of Ruby.
I dug through the perl script I am using to get an idea of exactly what it is doing, and it looks like it is forming a packet of 6 bytes. For instance to change to channel 244:
0xFA leading byte
0xA6 "change channel" command
0x00 channel high byte
0xF4 channel low byte
0xFF trailing byte
0xFF trailing byte
The sat box sends back a confirmation of this, but I am really not concerned with receiving events from it since it is always turned on anyway. I also dug up a page documenting this protocol, if interested http://www.dar.net/~andy/tivo/rca_dss_serial.html
How would I implement this in a generic serial device?
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 03, 2008, 03:22:07 pm
I would suggest messaging ddamron here on the forums. He is our resident GSD hacker.

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: posde on October 03, 2008, 06:37:01 pm
I had already read through that page, but it really didnt help me, perhaps because I know nothing of Ruby.
[...]
How would I implement this in a generic serial device?

You do not need to know Ruby to do a GSD. Basically all you do is <$"\x0201POF\x03"$>  <-- This transmits 0x02 01POF 0x03  over rs-232. Have a look at Device Template 1779, the Pioneer Elite TV. It shows very nicely, how easy it is to do a simple GSD.

After you have your device controlled to do stuff, you can look at the Yamaha RX-V1500 template and add receiving capabilities to your device, so you will be able to let LinuxMCE know, when you did something on the box itself.

Again, this has nothing to do with knowing Ruby, but it helps to know a tiny little bit programming, even if it was just a single high school class in "Programming 101" during spring break ;)

rgds
Oliver
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 04, 2008, 01:46:32 am
I'm sorry, perhaps I am just dense or something but this is not making much sense to me. It looks like the whole generic serial device thing is meant to only emulate button presses on a remote control, and that is not what I want here.
Is there really no way to just have it execute an external script anytime the channel needs changed, and pass that script just a single argument of the channel number? Thats all I need to get this working the same as it is right now with MythtTV.
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 04, 2008, 01:58:29 am
The GSD allows for the creation of new devices in LinuxMCE.

Since the satellite box is an A/V device, it should have commands defined for the individual functions that would normally be present on the remote. This includes the number digits.

This is so that not only can the satellite box be used in MythTV, but it can also be used in Live TV mode as well. This way, you can hook up your satellite box directly to the TV as well as to the tuner card, and once you have device templates for your TV and Amplifier, LinuxMCE can control them all, from a single remote, sending button presses to the correct devices. A bit more than your average mythtv setup, but also a lot more integrated.

So, while you do need commands for the individual channel changing, you can also override the Tune to Channel as well to send a channel number.

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 04, 2008, 02:25:10 am
My system right now consists of just the TV, sat box, and audio system.
The only functions used on the TV are on/off.
The only function used on the sat box is "change channel".
The only functions used on the audio system are vol up/vol down.
The only function managed by MythTV is changing channels, everything else is handled by the devices normal IR remotes. The TV has no connection to the sat box; that is to say live tv is managed through MythTV and only MythTV. I should imagine it would become very confusing very quickly with multi-room setups if AV equipment was connected directly to each other rather than routed through LinuxMCE... If live tv is not or cannot be managed by LinuxMCE in the same manner as MythTV (on disk ring buffer for pausing, etc), then I will stop right here, that is the primary use of the system. I accidently hit the "TV" option once in the UI and it attempted to launch MythTV though so I assume it works as I expect.
With all that in mind, I see no reason to implement anything other than the sat box "change channel" command at this time, since I am only looking for equivalent functionality from the setup. I dont even have the possibility to control any of the other equipment yet, as they have no serial or usb interfaces and I do not have any IR transmitters. While there are 10 key commands in the protocol, I am worried about performance of the sat box in this case. It is painfully slow to respond to them on the remote.
If I need to get dirty with code to solve this, dont be afraid to get technical with me. I have over 10 years experience as a linux sysadmin and just as much with just about every scripting language except ruby (php, javascript, perl, tcl, etc).
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 04, 2008, 02:29:25 am
**hmm** you're not getting it.

I'm trying to tell you what to do.

(1) Implement the protocol presses for the individual buttons, and the channel change will work as expected.

if you want to override the tune to channel command to send it all at once, then do so.. but there is no need to do this..

If you do this correctly, then:

(1) mythTV will be able to change channels
(2) liveTV will be able to work (and yes, even with liveTV, you can bounce the same stream to multiple media directors)
(3) the on-orbiter EPG will also work and change channels in both mythTV and liveTV mode.

If you don't want liveTV then don't use it... but there is a specific reason we integrate into DCE, instead of duct taping on a script.

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 04, 2008, 06:29:39 am
I am getting it, I am just not understanding why such a simple thing like changing a channel has to be made so complicated.
In any case I will find out tomorrow how or if it works, since I will finally have a gap in my recording profiles long enough to swap out the hardware (the new system is currently just hooked up to a monitor with no a/v equipment installed). Heres to hoping a PVR-350 will be detected the same as a 250 :)
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 04, 2008, 07:22:36 am
we currently do not have a device template for the 350...although the 250 could be used as a pattern.. or you could specifically set a 250 in the media directors page in the web admin.

and it's not complicated.. it's just no longer duct taped on, like it is in MythTV. Any part of the system can send messages to any other part...this is used to great effect for many powerful features in the system.

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 04, 2008, 10:11:19 pm
Ok so I am confused again, but no surprise there I am sure. At this point I am not entirely sure why the capture card and channel changing even needs to be setup in LinuxMCE as it seems MythTV takes care of all of it. At least it seems to be working fine with the PVR-350 setup only in Myth, and using an external channel changing script exactly how i had it setup previously. The only thing I still need to get working is the remote that came with the PVR card, but that shouldnt be too difficult.
Did I just make an incorrect assumption about how this all works, or is there something else going on?
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 05, 2008, 12:10:41 am
you CAN circumvent and put in your own channel changing script.. but damn it, that's duct taping it!

*hmm*

please look around in the system... you'll find that there is a lot more going on than just MythTV. It is important that DCE handles talking to all the devices, so that everything can be integrated smoothly together.

I will not respond again, until you dig in, and read! or even better...actually look around and explore the system!

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 05, 2008, 12:54:45 am
I have read everything I have come across so far, and nothing talks about this. And I have gone through setting after setting in the admin web interface. So all I really have to go on is what I can guess by poking at things. I filled out all the stuff for the serial control, but as far as i can tell it will never be used. Again I have to guess at this because nothing talks about how this actually works.
I have yet to see ANY integration between LMCE and MythTV. I press the "TV" option and I am dumped into myth in live tv mode. Any keys I press appear to be handled by myth directly whout LMCE getting involved.
So, thanks for nothing, other than a really lame "RTFM".
Title: Re: Control DirecTV receiver via serial
Post by: Zaerc on October 05, 2008, 02:33:49 am
I have read everything I have come across so far, and nothing talks about this. And I have gone through setting after setting in the admin web interface. So all I really have to go on is what I can guess by poking at things. I filled out all the stuff for the serial control, but as far as i can tell it will never be used. Again I have to guess at this because nothing talks about how this actually works.
I have yet to see ANY integration between LMCE and MythTV. I press the "TV" option and I am dumped into myth in live tv mode. Any keys I press appear to be handled by myth directly whout LMCE getting involved.
So, thanks for nothing, other than a really lame "RTFM".

Posde gave you a good pointer in the right direction, you however replied with "that is not what I want"... so suit yourself.

PS. Does pressing F6, F7 or F8 also appear to be handled by mythtv?

Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 05, 2008, 07:50:16 am
what do you want to know as to how it works? I know our documentation can always use improvement.. but what are you confused about specifically?

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: hari on October 05, 2008, 09:41:00 am
I'm sorry, perhaps I am just dense or something but this is not making much sense to me. It looks like the whole generic serial device thing is meant to only emulate button presses on a remote control, and that is not what I want here.
no, thats wrong. A GSD is a quick way to create a DCE device that uses external commands, serial, usb converters or ethernet.
 
Quote
Is there really no way to just have it execute an external script anytime the channel needs changed, and pass that script just a single argument of the channel number? Thats all I need to get this working the same as it is right now with MythtTV.
hehe, you can use super-glue and mix whatever you want. It is just the basic principle concept behind LMCE is: everything is a DCE device. Otherwise devices could not uniformly interact. That is e.g. needed for AV pipes to work properly in your case.

If you don't aim for having your devices controllable by DCE, there is not much point about using LMCE. For a quick solution, if "you do not understand ruby", just use the ruby system() call (iirc) in the GSD to fire your external perl script.

best regards,
Hari
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 05, 2008, 06:57:01 pm
The confusion for me right now is understanding when the GSD is used. For instance if I start an orbiter (on my desktop PC, controlling the LMCE PC) and press a number button, should the corresponding number in the GSD be activated? Is there any easy way to test the GSD functions manually? I've tried looking in log files (/var/log/pluto/[number]_Generic_Serial_Device.log) and have seen some activity, but nothing that appears to correspond with any event I initiate. I have filled out the 0-9,enter/go,power on/off commands in the GSD.
Now then I also don't have the capture card setup as a device in LMCE, mostly because there is no template for a PVR-350 (and there were unanswered questions about the device id in the forums). But theres confusion here too; do I really need to set it up in LMCE or is Myth the only thing that cares about it? Same goes for TV and audio system, which I am quite happy controlling directly via remote (at least for now). I do however want to use the remote that came with the PVR-350 and am not completely sure how to set that up.
So I am completely willing to do things the right way, but am having a hard time figuring out exactly what that is and how to achieve it.
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 05, 2008, 07:04:30 pm
have you tested each command to see if it properly sends to the reciever (using the test button?)

You should do this starting from the wizard > a/v devices screen, so that the system understands which device you are talking to, and therefore where to send the commands.

-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 05, 2008, 07:34:31 pm
No I had not noticed that test button previous, it is exactly what I was looking for. Unfortunately nothing happens when I press it, though it reports that the command was sent to device #1 (the sat box was added as device #39?). I see nothing in the logfile for device 39.
I have also confirmed that the serial commands I formed do indeed work (send the bytes for a "2" keypress in perl and it acts as if i had pressed the "2" button on the remote).
Title: Re: Control DirecTV receiver via serial
Post by: tschak909 on October 05, 2008, 09:06:36 pm
can you send me screen captures of your device template page, and your wizard > a/v devices page?

So i can have a point to start from?

Thanks
-Thom
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 06, 2008, 03:33:54 am
Sure thing, I will email them shortly. Thanks for helping out, and puting up with my frustrations.
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 08, 2008, 06:45:23 am
Still never made it any further with the channel changing, but I did manage to apply enough duct tape (since you like that term so much :) ) to turn it into a usable replacement for my prior setup. I ended up just using my existing perl script as an "external channel change program" in mythtv. Its not ideal, i know, but works for a system that will never be expanded beyond one core/hybrid (I love alone, in a 500 sq ft house). Someday I would like to revisit this and get it going the right way, but probably not until getting hardware that is better supported out of the box. I also managed to get the remote working that came with my PVR-350. After blundering around in the admin interface (and manually loading the lirc_i2c kernel module and copying lirc configs from my old setup) lirc fired up, but only 2 of the buttons did anything. So I tried changing lircd.conf, only to have my changes be overwritten :P Looked around on the wiki and saw that I needed to add a row to the _main.RemoteMapping table. So copied the existing default mapping, made it more generic to suit the low number of buttons, reloaded the router, and presto, remote works.
So here I am, with the same MythTV functionality I had before, but with the following extras:
1) SPDIF audio works. No matter how much i tweaked the old setup, it would never do anything but occasionally make some really bad noises when I tried using SPDIF (same hardware). Finally utilizing the DTS decoder on my audio system is incredible!
2) Better Audio / Video / DVD browsing / playback interfaces. The MythTV UI is great for TV, but man did they miss the mark when it comes to browsing mp3s.
3) Someday I can experiment with the home automation, security, telehpony, etc. No immediate plans for this.
4) The flickr screensaver is pretty :)
A big thanks to those of you that helped me or at least just tolerated my rantings. I'm sure you will be seeing more of me as I try to remove some of the duct tape I had to use to get this far, but for now I am happy.
Title: Re: Control DirecTV receiver via serial
Post by: posde on October 09, 2008, 08:13:17 pm
Hello merkur2k,

nice to hear that you got some progress, even though not the way the system was intended.

Play a little bit more with it, and I am sure, one day it will Click for you, and you see why things did not work before. Good luck, and thanks your feedback regarding stuff working.

rgds
Oliver
Title: Re: Control DirecTV receiver via serial
Post by: merkur2k on October 10, 2008, 02:01:21 am
One further quick question I did have; is there any easy way to completely disable the generic serial device functionality? Its eating alot of cpu (5-10% constant) and occasionally interferes with my channel changing script.