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)))
 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 bp_transparent_bridge(uart_speed, device, speed):
  """Script enables transparent UART bridge mode on the Bus Pirate

  UART_SPEED - overrides UART mode speed if passed. Default: 9600
  """
  print('\nBus Pirate transparent UART bridge mode enabler. Hi!\n')
  bp = UART(device, speed)
  bp.enter()
  print(f'Mode name: {bp.mode}\nMode version: {bp.modestring}\n')

  bp_uart_cfg = generate_uart_cfg_mask(
    BUS_PIRATE_UART_PIN_OUTPUT,
    BUS_PIRATE_UART_DATABITS_PARITY,
    BUS_PIRATE_UART_STOPBITS,
    BUS_PIRATE_UART_RX_POLARITY
    )
  set_uart_cfg(bp, bp_uart_cfg)
  set_uart_speed(bp, BUS_PIRATE_UART_SPEED_MASKS[uart_speed])

  print('Enabling transparent UART bridge\n')
  bp.enter_bridge_mode()
#   bitmapsize = im.size[0]*(im.size[1])//8

print "Converting bitmap..."
picturebitmap = []
# BW GIF pixels have a 0 value for white and 1 value for black.
for col in range(0, im.size[0]):
    for row in range(0, im.size[1] // 8):
        pixblock = 0
        for subrow in range(0, 8):
            pixblock = pixblock | (im.getpixel((col, row * 8 + subrow)) <<
                                   (7 - subrow))
        picturebitmap.append(pixblock)

# Now initialize the display: we want to display a full screen picture, so
# we will clear the screen, place the cursor home.
uart = UART("COM4", 115200)
print "Entering binmode: ",
if uart.BBmode():
    print "OK."
else:
    print "failed."
    sys.exit()

print "Entering binary UART mode: ",
if uart.enter_UART():
    print "OK."
else:
    print "failed."
    sys.exit()

print "Reset display (toggle AUX): ",
Example #5
0
#!/usr/bin/env python
# encoding: utf-8

import os, sys
import serial

from time import sleep

from pyBusPirateLite.UART import *
from pyBusPirateLite.BitBang import *

# change this path
BUS_PIRATE_DEV = "/dev/ttyUSB-buspirate"

bp = UART(BUS_PIRATE_DEV, 115200)

print "Entering binmode: ",
if bp.BBmode():
    print "OK."
else:
    print "failed."
    sys.exit()

bp.raw_set_pins(BBIOPins.POWER | BBIOPins.PULLUP)


def on():
    bp.raw_cfg_pins(PinCfg.CS)


def off():
Example #6
0
OFFSET = 10
TRIGGER_LEV_RES = 0.05
TRIG_CAL = 0.99
DEFAULT_TIME_DIV = 1
DEFAULT_TRIGGER_LEV = 1.0
DEFAULT_TRIGGER_MODE = 0



DATA_RATE = 5720.0 #measures/second (estimated experimenticaly)

DEFAULT_TIME_SCALE = RES_X / DATA_RATE #default time in seconds to make one window fill

pygame.init() 

bp = UART(BUS_PIRATE_DEV,115200)

print "Entering binmode: ",
if bp.BBmode():
	print "OK."
else:
	print "failed."
	sys.exit()
	
window = pygame.display.set_mode((RES_X, RES_Y)) 
background = (0,0,0)
line = (0,255,0)
trig_color = (100,100,0)

time_div = DEFAULT_TIME_DIV
trigger_level = DEFAULT_TRIGGER_LEV
#   bitmapsize = im.size[0]*(im.size[1])//8

print "Converting bitmap..."
picturebitmap = []
# BW GIF pixels have a 0 value for white and 1 value for black.
for col in range(0, im.size[0]):
    for row in range(0, im.size[1] // 8):
        pixblock = 0
        for subrow in range(0, 8):
            pixblock = pixblock | (im.getpixel((col, row * 8 + subrow)) << (7 - subrow))
        picturebitmap.append(pixblock)


# Now initialize the display: we want to display a full screen picture, so
# we will clear the screen, place the cursor home.
uart = UART("COM4", 115200)
print "Entering binmode: ",
if uart.BBmode():
    print "OK."
else:
    print "failed."
    sys.exit()

print "Entering binary UART mode: ",
if uart.enter_UART():
    print "OK."
else:
    print "failed."
    sys.exit()

print "Reset display (toggle AUX): ",