|
SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
External tuning command in SageTV V9 Linux
I want to control my DirecTV Genie HR44 by using http calls to the STB. It looks like they disabled "/tv/tune?major=", but "/remote/processKey?key=" still seems to work.
I can send "remote keys" to the STB by simply doing: Code:
curl 192.168.1.79:8080/remote/processKey?key=$key EDIT: /tv/tune?major=$channel_number works via curl, but not firefox Last edited by turak; 11-08-2015 at 12:36 AM. |
#2
|
||||
|
||||
I've written this quick perl script to change channels. It's a work in progress, but it seems to work well. I just need to figure out how to get sage to call it.
I can change to channel 33 by running: /opt/sagetv/server/curl_remote.pl 0033 Here is my script: Code:
root@banshee:/opt/sagetv/server# cat curl_remote.pl #!/usr/bin/perl use strict; my $stb_ip = '192.168.1.79'; my $log = '/var/log/curl_remote.log'; my $param = shift; &parse_input( $param ); sub parse_input() { my $keys = shift; chomp $keys; &logit( "$keys" ); foreach my $char ( split //, $keys ) { if ( $char =~ /\d/ ) { print "Char = $char \n"; open ( CURL, "curl $stb_ip:8080/remote/processKey?key=$char |" ); while (<CURL>) { my $output = $_; chomp $output; &logit( $output ); } } } } sub logit() { my $message = shift; my $timestamp = &getLoggingTime(); open ( LOG, ">> $log" ); print LOG "[$timestamp]\t$message\n"; close LOG; } sub getLoggingTime() { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); my $nice_timestamp = sprintf ( "%04d%02d%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec); return $nice_timestamp; } root@banshee:/opt/sagetv/server# |
#3
|
||||
|
||||
Quote:
EDIT: I was wrong. You don't need the minor. It just wasn't working when I plugged it into firefox. It works fine if I use curl instead. Last edited by turak; 11-08-2015 at 12:38 AM. |
#4
|
||||
|
||||
I use GenTuner on linux to change channels (not to directtv, but to some other stb)
https://github.com/jwittkoski/GenericTunerPlugin It's a SageTV tuner plugin that delegates the actual "tuning" to command/script.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#5
|
||||
|
||||
Thanks.. I was just playing with your old ExternalCommandTunerPlugin-1.5.zip
|
#6
|
||||
|
||||
OK. I've modified my script to work with gentune. I just need to figure out how to get SageTV to load the GenericTunerPlugin.so that I copied to the irtunerplugins directory.
Code:
#!/usr/bin/perl # This script controls my DirecTV Genie (hr44) STB. Just update the IP addess # below and you should be good to go. You can also turn off debug if you don't # want the script to write to a log file. You can get a list of mini's with the # get_clients argument. Set your genie's IP below and run "tune.pl get_clients" # to list the address if your clients. use strict; # List your STB's and IP addresses below. Use 'xxx.xxx.xxx.xxx|MacAddrOfClient' # for mini's. Feel free to comment out and tuners that you don't need. my %stbs = ( 'DirecTV-Tuner-1' => '192.168.2.243', 'DirecTV-Tuner-2' => '192.168.2.243|2C088C089B22', # 'DirecTV-Tuner-3' => '192.168.1.79', ); my $log = 'c:\TuneChannel\tune.log'; # Location of logfile. #my $log = '/var/log/tune.log'; # Location of logfile Linux. my $debug = 1; # Set to 1 to turn logging on. # Set to 0 to turn logging off. my $micro_send = 0; # Set to 1 to send one digit at a time # to the STB instead of the whole channel. # Set to 0 to send the whole channel number. my $command = $ARGV[0]; my $remote = $ARGV[1]; my $channel = $ARGV[2]; &logit( "Received COMMAND = $command | REMOTE = $remote | CHANNEL = $channel" ); &get_clients if ( $command eq "get_clients" ); &list_keys if ( $command eq "KEYS" ); &send_keys( $channel ) if ( $command eq "TUNE" ); &list_tuners if ( $command eq "REMOTES" ); print "OK\n" if ( $command eq "CAN_TUNE" ); sub list_tuners() { foreach my $tuner ( keys %stbs ) { print $tuner . "\n"; } } sub get_clients() { my ( $ip_addr, $client_addr ); foreach my $key ( keys %stbs ) { ( $ip_addr, $client_addr ) = split ( /\|/, $stbs{$key} ); if ( $client_addr eq '' ) { open ( CURL, "curl -s $ip_addr:8080/info/getLocations |" ); while (<CURL>) { my $output = $_; print $output; chomp $output; &logit( $output ); } close CURL; } } } sub list_keys() { my @keys = ( '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'OK' ); foreach ( @keys ) { print "$_\n"; } } sub send_keys() { my ( $ip_addr, $client_addr ); my $keys = shift; chomp $keys; &logit( "$keys" ); ( $ip_addr, $client_addr ) = split ( /\|/, $stbs{$remote} ); $client_addr = '&clientAddr=' . $client_addr if ( $client_addr ne '' ); open ( CURL, "curl -s $ip_addr:8080/remote/processKey?key=poweron$client_addr |" ); while (<CURL>) { my $output = $_; chomp $output; &logit( $output ); } if ( $micro_send ) { foreach my $char ( split //, $keys ) { if ( $char =~ /\d/ ) { open ( CURL, "curl -s $ip_addr:8080/remote/processKey?key=$char$client_addr |" ); while (<CURL>) { my $output = $_; chomp $output; &logit( $output ); } } } } else { open ( CURL, "curl -s $ip_addr:8080/tv/tune?major=$channel$client_addr |" ); while (<CURL>) { my $output = $_; chomp $output; &logit( $output ); } } } sub logit() { my $message = shift; my $timestamp = &getLoggingTime(); if ( $debug ) { open ( LOG, ">> $log" ); print LOG "[$timestamp]\t$message\n"; close LOG; } } sub getLoggingTime() { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); my $nice_timestamp = sprintf ( "%04d%02d%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec); return $nice_timestamp; } Updated to support Genie mini clients. Last edited by turak; 08-17-2018 at 03:28 PM. |
#7
|
||||
|
||||
I figured out why GenericTunerPlugin.so wasn't loading. I had to recompile it as a 64bit object since I'm running 64bit SageTV.
In Makefile change: CFLAGS = -m32 -fPIC -D_FILE_OFFSET_BITS=64 To: CFLAGS = -m64 -fPIC -D_FILE_OFFSET_BITS=64 |
#8
|
||||
|
||||
Except that SageTV Server core dumps when I select "Generic Tuner" with nothing in the logs. I was tailing sagetv_0.txt when it dumped it's core and nothing got logged.
./startsagecore: line 48: 11778 Aborted (core dumped) java -Djava.awt.headless=$HEADLESS $JAVAMEM -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=25 -XX:GCTimeRatio=24 -XX:ThreadPriorityPolicy=1 $JAVAOPTS -cp Sage.jar:.:/:$(echo JARs/*.jar | sed 's/ **/:/g') sage.Sage 0 0 x "sagetv Sage.properties" 0>&- |
#9
|
||||
|
||||
Sage blows up every time I select Generic Tuner. hs_err log attached. I don't really know how to debug this.
hs_err_pid16042.log.txt |
#10
|
|||
|
|||
Likely the native code needs some tweaks to work as a 64bit library. Most C/C++ code written for 32bit systems won't play so nice if just compiled to 64bit unless you make it 64bit compatible. The change in pointer sizes and integer sizes is usually why code goes boom when compiled to 64bit. Successfully compiled != correct, especially if it compiled successfully, but with warnings.
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#11
|
||||
|
||||
There weren't any warnings, but then the Makefile didn't have any warning flags.
|
#12
|
||||
|
||||
Quote:
I suppose you are correct. The source code probably isn't 64bit clean. I don't suppose anyone wants to comb through 400ish lines of C code to port it to 64bit? Are there any other options for calling an external script to handle channel tuning? |
#13
|
||||
|
||||
I looked at the source code, and there is very little that I can see that would be affected by 64bit.
If you checkout my repo... https://github.com/stuckless/GenericTunerPlugin I've added a TestTuner executable... basically it links about the GenericTunerPlugin.o and then calls OpenDevice, MacroTuner, etc. That can be used to verify if GenTuner is working on your system. You can probably modify the TestTuner to have it send a "real" channel, current, I'm sending 256.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#14
|
||||
|
||||
Thanks so much for the test program. WAF is not so good at the moment. The test program changes the channel flawlessly. So it doesn't look like it's a 64bit issue.
Any interaction with the gentuner shared object from SageTV still results in: root@banshee:/opt/sagetv/server# ./startsagecore: line 48: 27809 Aborted (core dumped) java -Djava.awt.headless=$HEADLESS $JAVAMEM -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=25 -XX:GCTimeRatio=24 -XX:ThreadPriorityPolicy=1 $JAVAOPTS -cp Sage.jar:.:/:$(echo JARs/*.jar | sed 's/ **/:/g') sage.Sage 0 0 x "sagetv Sage.properties" 0>&- I don't know where to go from here. SageTV also dumps it's core when it tries to stop recording from my HD PVR. The recording/playback is just fine until it tries to stop the recording. Then it crashes. EDIT: The gentuner plugin worked long enough for me to add a tuner and select a remote, but then caused SageTV to crash again. Now Sage crashes any time I try to select a new remote via the gentuner plugin or if Sage tries to send a channel change. Last edited by turak; 11-08-2015 at 11:04 AM. |
#15
|
||||
|
||||
Here is my gentuner perl script for controlling my DirecTV Genie (HR44) if anyone wants it or if you want to add it to github. I added .txt extension so the forums would let me upload it.
gentuner.HR44.txt EDIT: - I updated this to support multiple STB's - I was missing a : in the poweron command Last edited by turak; 11-11-2015 at 12:26 AM. |
#16
|
||||
|
||||
I'm wondering if you problem isn't the Generic Tuner Plugin, but rather what happens AFTER that which is accessing the HDPVR.
BTW, are you running this as root, or a normal sagetv user?
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#17
|
||||
|
||||
I did the following to install ffprobe and now the gentunerplugin seems to be working for the moment.
add-apt-repository ppa:mc3man/trusty-media apt-get update apt-get dist-upgrade apt-get install ffmpeg reboot maybe the dist-upgrade fixed something. Quote:
Quote:
|
#18
|
||||
|
||||
And it's crashing again...
|
#19
|
||||
|
||||
This is interesting... I don't think it's the GenTuner plugin at all. I just did the following:
I think the problem is with whatever is loading the plugins |
#20
|
||||
|
||||
Is anyone using tuning plugins with 64bit SageTV 9.0.3.170 on Ubuntu 14.04?
Did I install SageTV correctly? I did the following: I downloaded the files from github. I untarred the .tar.gz in /opt/sagetv/server. I created the /var/media/ directories. I installed the .deb. I copied in my wiz.bin from my windows server. I copied the Sage.jar into the /opt/sagetv/server directory. I added 64bit java7 to the PATH in my start scripts. I configured samba. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
External Command Tuner Plugin for Linux | stuckless | SageTV Linux | 36 | 05-16-2017 03:11 PM |
Plugin Request: Run external command on error | tedson | SageTV v7 Customizations | 10 | 06-14-2010 07:32 PM |
Adding custom command for launching external program | dinki | SageMC Custom Interface | 14 | 01-22-2010 08:16 AM |
Getting the status after running an external command | pedz25 | SageMC Custom Interface | 0 | 04-05-2009 06:55 AM |
Fail to launch PowerDVD Ultra as external command | basset | SageTV Customizations | 4 | 12-20-2007 11:59 AM |