Rose-Hulman Robotics Team

Changeset 648 for trunk/software

Show
Ignore:
Timestamp:
02/01/10 19:51:05 (2 years ago)
Author:
mosttw
Message:

Slightly questionable attempt to convert setspeed to setdc.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/rb/drive.py

    r598 r648  
    1818 
    1919''' 
    20 Functions to communicate with the `2008 legacy motor controllers`_  
    21 via RS-232. 
    22  
    23 .. _2008 legacy motor controllers: http://www.rhitrobotics.org/wiki/igvc/2008-motor-control 
     20Communicate with the 2009 motor controllers via RS-232. 
    2421''' 
    2522 
     
    4643# Max speed 
    4744MAX      = 400  
     45# Max duty cycle 
     46DC_MAX = 255 
    4847 
    4948Ok, Err = range(2) 
     
    170169                logger.info("Motor %s main starting", self.dev) 
    171170                while self.drive.running: 
    172                         self._send("setspeed", self.target * MAX) # Ping! 
     171                        self._send('setdc', self.target * DC_MAX) # Ping! 
    173172                        time.sleep(.05) 
    174173                logger.info("Motor %s main terminating", self.dev) 
    175                 self._send("setspeed", 0) 
     174                self._send('setdc', 0) 
    176175         
    177176        def _send(self, type, *t_data): 
    178177                #print "Acquiring drive %s lock" % (self._port_name,) 
    179                 self._port_lock.acquire() 
    180                 try: 
     178                with self._port_lock: 
    181179                        t, r = messages[type] 
    182180 
     
    216214                                return r_data[0] 
    217215                        return r_data 
    218                 finally: 
    219                         self._port_lock.release()