Update of /cvsroot/freevo/freevo/WIP/RobShortt
In directory sc8-pr-cvs1:/tmp/cvs-serv7315

Modified Files:
        irtrans-echostar.py 
Log Message:
Can send some good signals now.  Still a WIP.


Index: irtrans-echostar.py
===================================================================
RCS file: /cvsroot/freevo/freevo/WIP/RobShortt/irtrans-echostar.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** irtrans-echostar.py 24 Sep 2003 00:08:07 -0000      1.1
--- irtrans-echostar.py 6 Oct 2003 02:16:32 -0000       1.2
***************
*** 37,40 ****
--- 37,43 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.2  2003/10/06 02:16:32  rshortt
+ # Can send some good signals now.  Still a WIP.
+ #
  # Revision 1.1  2003/09/24 00:08:07  rshortt
  # Module for sending IR signals to echostar boxes, the Notes say it all.
***************
*** 67,209 ****
  import array
  import ioctl_util
  
  LIRC_SET_SEND_CARRIER    = ioctl_util._IOW('i', 0x00000013, 'I')
  LIRC_SET_SEND_DUTY_CYCLE = ioctl_util._IOW('i', 0x00000015, 'I')
  
- MODULATION_FREQ = 57600
  
! ## 0 to 100, where 100=strongest? 
! DUTY_CYCLE = 50
  
! ## 1 block takes up 16bits*2+2, or 34 samples.  trans_serial
! ## has a 256 sample buffer, so we can send max 7 back to back
! ## signals.
! NUM_BACK_TO_BACK = 3
  
! POWER_BITS = 0xf7ff; ## power button bits 
! PULSE_LEN = 350
! HEADER_SPACE = 6000
! ONE_LEN = 2700
! ZERO_LEN = 1700
  
! data = []
! fd = None
! duty_cycle = None
! freq = None
! num_times_to_send = 1
  
! ## XXX: change to use the lircd.conf parser that I just wrote!
! LOOKUP = {
!   'tv/video'       :  0x000000000000A3FF,
!   'power'          :  0x000000000000F7FF,
!   'menu'           :  0x000000000000D3FF,
!   'page_up'        :  0x000000000000C3EF,
!   'page_down'      :  0x000000000000E3EF,
!   'guide'          :  0x000000000000AFFF,
!   'pointer_up'     :  0x00000000000097FF,
!   'pointer_left'   :  0x0000000000008FFF,
!   'pointer_right'  :  0x0000000000009FFF,
!   'pointer_down'   :  0x00000000000087FF,
!   'select'         :  0x000000000000BFFF,
!   'recall'         :  0x00000000000093FF,
!   'info'           :  0x000000000000FFFF,
!   'view'           :  0x000000000000A7FF,
!   'cancel'         :  0x000000000000B7FF,
!   'sys_info'       :  0x0000000000006FFF,
!   'record'         :  0x00000000000083FF,
!   '1'              :  0x000000000000EFFF,
!   '2'              :  0x000000000000EBFF,
!   '3'              :  0x000000000000E7FF,
!   '4'              :  0x000000000000DFFF,
!   '5'              :  0x000000000000DBFF,
!   '6'              :  0x000000000000D7FF,
!   '7'              :  0x000000000000CFFF,
!   '8'              :  0x000000000000CBFF,
!   '9'              :  0x000000000000C7FF,
!   '0'              :  0x000000000000BBFF,
!   '*'              :  0x0000000000006BFF,
!   '#'              :  0x00000000000067FF,
!   ''               :  0
! }
!  
! button = 'power'
  
! devname = '/dev/trans'
  
! def transmit_signal(code):
!     fd = os.open(devname, os.O_RDWR)
!     if fd < 0:
!         sys.exit("Error: %d\n" % fd)
!     else:
!         print "Lirc Opened at %s" % devname
  
  
-     print 'LIRC_SET_SEND_CARRIER: %s' % LIRC_SET_SEND_CARRIER
-     r = fcntl.ioctl(fd, long(LIRC_SET_SEND_CARRIER), 
-                         struct.pack( "L", MODULATION_FREQ))
-     print 'LIRC_SET_SEND_CARRIER got %s' % r
-     #    printf("couldn't set modulation\n");
  
  
!     r = fcntl.ioctl(fd, long(LIRC_SET_SEND_DUTY_CYCLE), 
!                         struct.pack( "L", DUTY_CYCLE))
!     print 'LIRC_SET_SEND_DUTY_CYCLE got %s' % r
!     #    printf("couldn't set duty cycle");
  
  
!     ## fill up our buffer with signal data to send driver 
!     for k in range(NUM_BACK_TO_BACK):
!         data.append(PULSE_LEN)
!         data.append(HEADER_SPACE)
  
!         # v = lookup[li].code;
!         v = LOOKUP[button]
  
!         for i in range(16):
!             data.append(PULSE_LEN)
!             if (v & 0x8000):
!                data.append(ONE_LEN)
!                # print 'ONE_LEN'
!             else:
!                data.append(ZERO_LEN)
!                # print 'ZERO_LEN'
!             v <<= 1
!     print 'j: %d' % len(data)
      
-     for i in range(num_times_to_send):
-         print 'sending %s code %x\n' % (button, LOOKUP[button])
-         a1 = array.array('I', data)
-         al = a1.itemsize
-         print 'al: %s' % al
-         m = 0
-         tmp = ''
-         sio = StringIO.StringIO()
-         for stuff in data:
-             print 'data%d: %d' % (m, stuff)
-             tmp = struct.pack('I', stuff)
-             print 'tmp: %s' % tmp
-             sio.write(tmp)
-             sio.flush()
-             m += 1
-         readnum = (len(data)-1)*al
-         print 'readnum: %s' % readnum
-         sio.seek(0)
-         print 't2: %s' % sio.tell()
-         t2 = sio.read(readnum)
-         sio.flush()
-         print 't2: %s' % sio.tell()
-         print 't2: %s' % t2
-         os.write(fd, t2)
-         #os.write(fd, sio.read(readnum))
-         #print 'total: %s' % total
-         # tmp = stuff.tostring()
-         # tmp = struct.pack('%sI' % len(data), (data,))
-         #tmp = struct.pack('I', stuff)
-         #print 'tmp: %s' % tmp
-         #blah.write(tmp)
-         #os.write(fd, tmp)
-         sio.close()
-         os.close(fd)
-         time.sleep(1)
  
  
--- 70,224 ----
  import array
  import ioctl_util
+ import lirc_util
+ 
  
  LIRC_SET_SEND_CARRIER    = ioctl_util._IOW('i', 0x00000013, 'I')
  LIRC_SET_SEND_DUTY_CYCLE = ioctl_util._IOW('i', 0x00000015, 'I')
  
  
! class IRTrans:
  
!     MODULATION_FREQ = 57600
  
!     ## 0 to 100, where 100=strongest? 
!     DUTY_CYCLE = 50
  
!     ## 1 block takes up 16bits*2+2, or 34 samples.  trans_serial
!     ## has a 256 sample buffer, so we can send max 7 back to back
!     ## signals.
!     NUM_BACK_TO_BACK = 3
  
!     POWER_BITS = 0xf7ff; ## power button bits 
!     PULSE_LEN = 350
!     HEADER_SPACE = 6000
!     ONE_LEN = 2700
!     ZERO_LEN = 1700
  
!     duty_cycle = None
!     freq = None
!     num_times_to_send = 1
  
!     def __init__(self, conf='/etc/lircd.conf', device='/dev/trans', remote=None):
!         self.conf = conf
!         self.device = device
!         self.remotes = lirc_util.parse_lircd(self.conf)
!         lirc_util.dump_remotes(self.remotes)
!         self.fd = None
  
+         if not remote and len(self.remotes.values()) >0:
+             remote = self.remotes.values()[0]
+         self.remote = remote
  
  
+     def setChannel(self, chan):
+         chan = str(chan)
+         digits = len(chan)
  
!         self.prepareSend()
  
+         for i in range(digits):
+             # self.transmitButton(chan[i])
+             code = long(self.remote.codes.get(chan[i]), 16)
+             if not code:
+                 print 'No code for %s' % chan[i]
  
!             self.transmitSignal(code)
  
!         self.clean()
  
! 
!     def transmitButton(self, button):
!         code = long(self.remote.codes.get(button), 16)
!         if not code:
!             print 'No code for %s' % button
! 
!         print 'sending button: %s\n' % button
!         print 'sending code: %x\n' % code
!         self.prepareSend()
!         self.transmitSignal(code)
!         self.clean()
!     
!     
!     def prepareSend(self):
!         self.fd = os.open(self.device, os.O_RDWR)
!         if self.fd < 0:
!             sys.exit("Error: %d\n" % fd)
!         else:
!             print "Lirc Opened at %s" % self.device
!     
!     
!         print 'LIRC_SET_SEND_CARRIER: %s' % LIRC_SET_SEND_CARRIER
!         r = fcntl.ioctl(self.fd, long(LIRC_SET_SEND_CARRIER), 
!                             struct.pack( "L", self.MODULATION_FREQ))
!         print 'LIRC_SET_SEND_CARRIER got %s' % r
!         #    printf("couldn't set modulation\n");
!     
!     
!         r = fcntl.ioctl(self.fd, long(LIRC_SET_SEND_DUTY_CYCLE), 
!                             struct.pack( "L", self.DUTY_CYCLE))
!         print 'LIRC_SET_SEND_DUTY_CYCLE got %s' % r
!         #    printf("couldn't set duty cycle");
!     
! 
!     def clean(self):
!         os.close(self.fd)
      
  
+     def transmitSignal(self, code):
+         data = []
  
+         ## fill up our buffer with signal data to send driver 
+         for k in range(self.NUM_BACK_TO_BACK):
+             data.append(self.PULSE_LEN)
+             data.append(self.HEADER_SPACE)
+     
+             v = code
+             for i in range(16):
+                 data.append(self.PULSE_LEN)
+                 if (v & 0x8000):
+                    data.append(self.ONE_LEN)
+                 else:
+                    data.append(self.ZERO_LEN)
+                 v <<= 1
+         
+         for i in range(self.num_times_to_send):
+             print 'sending code: %x\n' % code
+             a1 = array.array('I', data)
+             al = a1.itemsize
+             print 'al: %s' % al
+             m = 0
+             tmp = ''
+             sio = StringIO.StringIO()
+             for stuff in data:
+                 # print 'data%d: %d' % (m, stuff)
+                 tmp = struct.pack('I', stuff)
+                 # print 'tmp: %s' % tmp
+                 sio.write(tmp)
+                 sio.flush()
+                 m += 1
+             readnum = (len(data)-1)*al
+             print 'readnum: %s' % readnum
+             sio.seek(0)
+             print 't2: %s' % sio.tell()
+             t2 = sio.read(readnum)
+             sio.flush()
+             print 't2: %s' % sio.tell()
+             # print 't2: %s' % t2
+             print 'fd: %s' % self.fd
+             os.write(self.fd, t2)
+             #os.write(fd, sio.read(readnum))
+             #print 'total: %s' % total
+             # tmp = stuff.tostring()
+             # tmp = struct.pack('%sI' % len(data), (data,))
+             #tmp = struct.pack('I', stuff)
+             #print 'tmp: %s' % tmp
+             #blah.write(tmp)
+             #os.write(fd, tmp)
+             sio.close()
+             # os.close(self.fd)
+             time.sleep(1)
+     
+ 
+ ir = IRTrans('/etc/lircd-transmit.conf')
+ # ir.transmit_button('1')
+ ir.setChannel('701')




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to