コード例 #1
0
class BusPirateStream(threading.Thread):
  def __init__(self, port='COM1', sinks=None, autoStart=True):
    threading.Thread.__init__(self)
    self.daemon = True
    
    self.dispatcher=AsynchDispatch(sinks=sinks,
      callbacks={'serial_data':[self.send]})
    
    try:
      self.bp = UART(port,115200)
    except:
      print 'Failed to start BusPirate'
      self.bp = None
    
    if autoStart:
      self.start()
    
  def run(self):
    if self.bp is not None:
      while(True):
        rx_bytes = self.bp.response(1000,True)
        if rx_bytes != '':
          self.dispatcher.dispatch(Message('serial_data',rx_bytes))
        
  def send(self, message):
    if self.bp is not None:
      self.bp.bulk_trans(len(message.data),map(ord,list(message.data)))
コード例 #2
0
ファイル: bus_pirate_stream.py プロジェクト: fgb/imageproc_py
class BusPirateStream(threading.Thread):
    def __init__(self, port='COM1', sinks=None, autoStart=True):
        threading.Thread.__init__(self)
        self.daemon = True

        self.dispatcher = AsynchDispatch(
            sinks=sinks, callbacks={'serial_data': [self.send]})

        try:
            self.bp = UART(port, 115200)
        except:
            print 'Failed to start BusPirate'
            self.bp = None

        if autoStart:
            self.start()

    def run(self):
        if self.bp is not None:
            while (True):
                rx_bytes = self.bp.response(1000, True)
                if rx_bytes != '':
                    self.dispatcher.dispatch(Message('serial_data', rx_bytes))

    def send(self, message):
        if self.bp is not None:
            self.bp.bulk_trans(len(message.data), map(ord, list(message.data)))
コード例 #3
0
ファイル: bus_pirate_stream.py プロジェクト: fgb/imageproc_py
    def __init__(self, port='COM1', sinks=None, autoStart=True):
        threading.Thread.__init__(self)
        self.daemon = True

        self.dispatcher = AsynchDispatch(
            sinks=sinks, callbacks={'serial_data': [self.send]})

        try:
            self.bp = UART(port, 115200)
        except:
            print 'Failed to start BusPirate'
            self.bp = None

        if autoStart:
            self.start()
コード例 #4
0
 def __init__(self, port='COM1', sinks=None, autoStart=True):
   threading.Thread.__init__(self)
   self.daemon = True
   
   self.dispatcher=AsynchDispatch(sinks=sinks,
     callbacks={'serial_data':[self.send]})
   
   try:
     self.bp = UART(port,115200)
   except:
     print 'Failed to start BusPirate'
     self.bp = None
   
   if autoStart:
     self.start()