[pvrusb2] Channel-change script
Per Christian Henden
perchrh at pvv.org
Wed Sep 14 10:36:00 CDT 2005
On Sunday 11 September 2005 01:42, Per Christian Henden wrote:
> On Sunday 11 September 2005 01:14, Mike Isely wrote:
> > With your permission I will add this to the pvrusb2 driver snapshot.
>
> Sure, go ahead.
> I'm not using ctl_freq_table_channel and ctl_freq_table_value
> with this script, didn't notice them until after I sent the script to the
> list.
>
> But if the frequencies file exists,
> then we can just do
>
> #!/bin/bash
> i=0
> freqlist=`cat ~perchrh/.tv/freqs|grep freq|cut -c 8-`
> for freq in $freqlist
> do
> echo $i > ctl_freq_table_channel/cur_val
> echo ${freq}000 > ctl_freq_table_value/cur_val
> let i++
> done
>
> to create the table.
>
> I don't notice any difference in speed or anything when changing
> channels by setting the frequency in ctl_freq_table_value
> and by programming in the table and using ctl_channel.
> Is there a difference in what code gets executed by the driver?
To answer this myself:
It seems that there sometimes is a difference, not sure under what conditions,
but audio from the previous channel plays for a little while when changing
channels by changing the frequency directly, i.e., when not using the
ctl_channel control.
So a script/program for changing channels should use the ctl_channel control.
> > It also seems like it might be useful to script the creation of the
> > mapping file as well...
>
> Yes, definetely.
Unfortunately, I can't do that now. I have a problem with both arms
(tendinitis) that gets worse when I use a mouse or a keyboard, so I try to
use them as little as possible for now.
I have a setup now where I can change the channel by using the remote.
I'll just send you what I have for now, and if anyone else wants to make it
suitable for general use, go ahead.
I run irexec as root.
/root/.lircrc contains
begin
button = 1
prog = irexec
repeat = 0
config = /usr/local/bin/byttkanal 1
end
begin
button = 2
prog = irexec
repeat = 0
config = /usr/local/bin/byttkanal 2
end
and so on
byttkanal is the script for changing channels.
It's obvious and looks like this
/// start byttkanal ///
#!/bin/sh
CHANNELID=$1
#check first if we are root
if [ $UID != "0" ]
then
echo You need to be root to change channels
exit
fi
#check parameters
if [ $# == "0" ]
then
echo Usage is $0 \<channel id\>
echo e.g. $0 3
exit
fi
if [ -x /sys/class/pvrusb2/ ]
then
ids=`find /sys/class/pvrusb2/ -type d -maxdepth 1 -mindepth 1`
for id in $ids
do
echo $CHANNELID > $id/ctl_channel/cur_val
done
else
echo PVR USB2 sysfs interface not found
fi
/// end byttkanal ///
To set up the channels I run
/// start programtv///
#!/bin/bash
i=0
freqlist=`cat ~perchrh/.tv/freqs|grep freq|cut -c 8-`
for freq in $freqlist
do
echo $i > ctl_freq_table_channel/cur_val
echo ${freq}000 > ctl_freq_table_value/cur_val
let i++
done
/// end programtv ///
It assumes the existence of a frequency file, as described earlier in this
thread.
-PER
More information about the pvrusb2
mailing list