[mythtv-users] Directv.pl stuttering changing channels
MacLaren, James M
maclaren at tulane.edu
Thu Oct 14 16:50:02 UTC 2010
I had some problems with directv.pl. I think I have a flaky satellite
box that isn't bad enough to get them to replace it. I found the
following c code somewhere and modified mildly for my own use. The
first write ensures the box is turned on. I have not had any missed
channel changes.
HTH
James
[james at Plugbox bin]$ cat /usr/local/bin/ch.c
#include <stdio.h>
#include <termio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
int chan;
int port;
int baud,parity,stop;
int iread;
struct termio term;
char buff[8];
if (argc != 2)
exit(1);
chan = atoi(argv[1]);
port = open("/dev/ttyUSB0",O_RDWR);
if (port < 0)
{
printf("Cannot open port");
exit(1);
}
baud=B9600;
parity=0;
stop=1;
/*
** Get the current setting just for grins.
*/
if(ioctl(port, TCGETA, &term))
{
perror("ioctl TCGETA");
return -1;
}
term.c_iflag = IGNBRK;
term.c_oflag = 0; /* No output processing
*/
term.c_lflag = 0; /* No lexical processing
*/
term.c_cc[VMIN] = 0; /* Block forever for one input
*/
term.c_cc[VTIME] = 100; /* character; no timeouts
*/
/*
** Set baud rate, eight bits, enable receiver, no modem control.
*/
term.c_cflag = baud | CS8 | CREAD | CLOCAL;
/*
** Set two stop bits if indicated.
*/
if(stop == 2)
term.c_cflag |= CSTOPB;
/*
** Enable parity checking, odd or even as indicated.
*/
if(parity != 0)
{
term.c_cflag |= PARENB;
if(parity == 1)
term.c_cflag |= PARODD;
}
/*
** Set up the port.
*/
if(ioctl(port, TCSETA, &term))
{
perror("ioctl TCSETA");
return -1;
}
// You may need to use this longer command format on newer boxes
sprintf(buff,"%c%c",0xfa,0x82);
write(port,buff,2);
sleep(1);
sprintf(buff,"%c%c%c%c%c%c",0xfa,0xA6,chan >> 8,chan &
0xff,255,255);
write(port,buff,6);
// Format for older boxes
//sprintf(buff,"%c%c%c%c",0xfa,0x46,chan >> 8,chan & 0xff);
//write(port,buff,4);
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mythtv.org/pipermail/mythtv-users/attachments/20101014/c50932ab/attachment.htm>
More information about the mythtv-users
mailing list