[mythtv-users] Re:Controlling a cable box
Guy Bayes
guy_jobs at yahoo.com
Mon Jul 21 13:26:06 EDT 2003
awesome i love you, i want to have your children (-:
How do you check the firmware on these wacky cable
boxes?
Guy
--- Ian Forde <ian at duckland.org> wrote:
> Okay - If you've got firmware version 7.54 or
> higher, and the serial
> port is enabled, you might be able to use the serial
> control scripts...
> see attached scripts...
>
> -I
>
> On Mon, 2003-07-21 at 09:27, ignacio at shaw.ca wrote:
> > I have a motorola dct
> >
> >
> >
> >
>
______________________________________________________________________
> > _______________________________________________
> > mythtv-users mailing list
> > mythtv-users at snowman.net
> >
>
http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
> --
>
> __________________________________
> Ian Forde, RHCE, CCSE, SCNA,
> SCDME
> CYTBeN, Inc.
> ian at duckland.org /
> ian at cytben.com
> > #!/bin/sh
>
> # Change Channel Script Wrapper for DCT-2000
> # written by Ian Forde
> # License: GPL. If you don't know what that is, you
> can look it up!
>
> PARM=$1
> PARMLEN=`echo $PARM | wc -c`
> if [ ${PARMLEN} -gt 4 ]; then
> echo "too high."
> exit
> elif [ ${PARMLEN} -eq 4 ]; then
> newparm=${PARM}
> elif [ ${PARMLEN} -eq 3 ]; then
> newparm="0"${PARM}
> elif [ ${PARMLEN} -eq 2 ]; then
> newparm="00"${PARM}
> fi
>
> /usr/local/bin/remote.py ${newparm}
> > #!/usr/bin/env python
>
> # Chris Griffiths, June 8th 2003
> (dct2000 at y-fronts.com)
> #
> # CRC calculator preset for CRC-CCIT suitable for a
> Motorola DCT2000
>
> # Please see
> http://rcswww.urz.tu-dresden.de/~sr21/crctester.c
> # and http://rcswww.urz.tu-dresden.de/~sr21/crc.html
> for the
> # original c code to this, a web based crc
> generator, and
> # a description of what these settings do
>
> order = 16;
> polynom = 0x1021;
> direct = 1;
> crcinit = 0x0000;
> crcxor = 0x0000;
> refin = 1;
> refout = 1;
>
>
> def reflect (crc, bitnum):
> i = 1 << (bitnum-1)
> j = 1
> crcout=0
> while i:
> if (crc & i):
> crcout = crcout | j
> j = j << 1
> i = i >> 1
>
> return (crcout)
>
> def calcrc(data_bytes):
>
> crcmask = (((1<<(order-1))-1)<<1)|1;
> crchighbit = 1<<(order-1);
>
> # compute missing initial CRC value
> if direct:
> crcinit_direct = crcinit;
> crc = crcinit;
> for i in range (order):
> bit = crc & 1;
> if bit:
> crc = crc ^ polynom;
> crc >>= 1;
> if bit:
> crc = crc | crchighbit;
> crcinit_nondirect = crc;
> else:
> crcinit_nondirect = crcinit
> crc = crcinit
> for i in range (order):
> bit = crc & crchighbit
> crc = crc << 1;
> if bit:
> crc= crc ^ polynom;
> crc = crc & crcmask;
> crcinit_direct = crc;
>
> # now compute the crc
> crc = crcinit_direct
>
> for i in range( len(data_bytes) ):
>
> c = ord(data_bytes[i])
> if refin:
> c = reflect(c, 8)
>
> j=0x80;
> while j:
> bit = crc & crchighbit
> crc = crc << 1
> if (c & j):
> bit = bit ^ crchighbit
> if bit:
> crc = crc ^ polynom
> j = j >> 1
>
>
> if refout:
> crc=reflect(crc, order)
> crc = crc ^ crcxor
> crc = crc & crcmask
>
> return(crc)
> > #!/usr/bin/python2.2
> #
> # Chris Griffiths, June 8th 2003
> (dct2000 at y-fronts.com)
> #
> # Simple program to send remote control sequences
> via serial port to a motorola dct2000
> # It does not respect sequence numbers, nor check
> the returned codes for success or failure
> #
> # Modified by Ian Forde (ian at duckland.org) (Sometime
> in early 2003 - I don't remember when...)
> #
> # Now it accepts 3-digit codes to make the channel
> changes...
>
> import serial # pyserial
> (http://pyserial.sourceforge.net/)
> import crcgen # CRC generator - preset to generate
> CCITT polynomial crc's
> import time # std python lib
> import sys
>
> # define button codes:
> ZERO='\x00'
> ONE='\x01'
> TWO='\x02'
> THREE='\x03'
> FOUR='\x04'
> FIVE='\x05'
> SIX='\x06'
> SEVEN='\x07'
> EIGHT='\x08'
> NINE='\x09'
> ONOFF='\x0A'
> CHAN_UP='\x0B'
> CHAN_DOWN='\x0C'
> VOLUME_UP='\x0D'
> VOLUME_DOWN='\x0E'
> MUTE='\x0F'
> MUSIC='\x10'
> SELECT_OK='\x11'
> ENTER='\x11'
> EXIT_KEY='\x12'
> LAST_CHANNEL='\x13'
> SWITCH_AB='\x14'
> FAVORITE='\x15'
> PPV_KEY='\x16'
> A_KEY='\x17'
> P_F='\x18'
> MENU='\x19'
> OUTPUT_CHAN='\x1C'
> FAST_FORWARD='\x1D'
> REVERSE='\x1E'
> PAUSE='\x1F'
> BROWSE='\x22'
> CANCEL='\x23'
> LOCK='\x24'
> LIST='\x25'
> THEME='\x26'
> GUIDE='\x30'
> RECORD='\x31'
> HELP='\x32'
> INFO='\x33'
> UP='\x34'
> DOWN='\x35'
> LEFT='\x36'
> RIGHT='\x37'
> DAY_PLUS='\x38'
> DAY_MINUS='\x39'
> PAGE_PLUS='\x3A'
> PAGE_MINUS='\x3B'
> B_KEY='\x27'
> C_KEY='\x28'
>
> def debug(ctrl_str):
> for hexChar in ctrl_str:
> print "%#x" % ord(hexChar),
> print '\n'
>
> def word2str(val):
> return chr((val & 0xFF00) / 256) + chr(val &
> 0x00FF)
>
> def get_response(ser):
> response = ''
> byte = ser.read()
> while byte:
> response = response + byte
> byte = ser.read()
> return response
>
> def calc_code(payload=""):
> #
> # code is 10 78 ll ll ss 40 pp pp cc 10 03
> # where ss = seq num, pp pp = payload (for a remote
> keypress first byte is 22), cc = crc
> # It seems the sequence number can be ignored - so
> long as we send this double sequence before it -
> # this is what embleem was using with the last
> sequence being the on/off keypress
> #
> # It also looks like we can only send one keypress
> at a time - although correct use of sequence number
> # be get that working
> #
> code = '\x78' + word2str(len(payload)+2) +
> '\x10\x40' + payload
> crc = crcgen.calcrc(code)
> code =
>
"\x10\x70\x00\x02\x03\x40\xc8\x27\x10\x03\x10\x78\x00\x03\x03\x40\x00\x68\x96\x10\x03"
> + '\x10' + code + word2str(crc) + '\x10\x03'
> return code
>
> def send_to_unit(ser, key_presses):
> #
> # Send each keypress, then get the returned status
> from the box (and subsequently ignore it)
> # You have to read the return code, otherwise the
> next send with fail
> #
> for key in key_presses:
> ser.write(calc_code('\x22' + key))
> print "Recvd: ",
> debug(get_response(ser))
>
> serCon = serial.Serial('/dev/ttyS1',baudrate=9600,
> bytesize=serial.EIGHTBITS,
> parity=serial.PARITY_NONE,
> stopbits=serial.STOPBITS_ONE, timeout=1,
> xonxoff=1,rtscts=0,)
>
> newchan = sys.argv[1]
> print "changing channel to ",newchan
>
> CHANCODE=''
> for num in [1, 2, 3]:
> if (newchan[num-1:num] == "1" ):
> CHANKEY=ONE
> if (newchan[num-1:num] == "2" ):
> CHANKEY=TWO
> if (newchan[num-1:num] == "3" ):
> CHANKEY=THREE
> if (newchan[num-1:num] == "4" ):
> CHANKEY=FOUR
> if (newchan[num-1:num] == "5" ):
> CHANKEY=FIVE
> if (newchan[num-1:num] == "6" ):
> CHANKEY=SIX
> if (newchan[num-1:num] == "7" ):
> CHANKEY=SEVEN
> if (newchan[num-1:num] == "8" ):
> CHANKEY=EIGHT
> if (newchan[num-1:num] == "9" ):
> CHANKEY=NINE
> if (newchan[num-1:num] == "0" ):
> CHANKEY=ZERO
> CHANCODE=CHANCODE+CHANKEY
>
> print "chancode is ",CHANCODE
>
> send_to_unit(serCon, CHANCODE)
>
> > _______________________________________________
> mythtv-users mailing list
> mythtv-users at snowman.net
>
http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
>
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the mythtv-users
mailing list