def __init__(self, useLogger=False): self.id = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] self.pose = [ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 ] self.nextPose = [ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 ] self.speed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.interpolating = False self.playing = False self.servoCount = 12 self.lastFrame = pyb.millis() self.port = UART_Port(1, 1000000) self.bus = Bus(self.port, show=Bus.SHOW_PACKETS) # Bus.SHOW_NONE # Bus.SHOW_COMMANDS # Bus.SHOW_PACKETS if useLogger: self.logger = Logger('sync_log.txt') else: self.logger = None
def pyboard_main(): from stm_uart_port import UART_Port serial = UART_Port(2, 1000000) bus = Bus(serial, show=Bus.SHOW_NONE) scan(bus)
from commander_rx import CommanderRx sysname = os.uname().sysname if sysname == 'Linux' or sysname == 'Darwin': import serial from serial_port import SerialPort from serial_bus import SerialBus port = '/dev/ttyUSB0' try: port = SerialPort(port, 38400) except serial.serialutil.SerialException: print("Unable to open port '{}'".format(port)) sys.exit() elif sysname == 'pyboard': from stm_uart_port import UART_Port port = UART_Port(6, 38400) else: print("Unrecognized sysname: {}".format(sysname)) sys.exit() crx = CommanderRx() while True: byte = port.read_byte() if not byte is None: #print('Byte =', byte) if crx.process_byte(byte) == CommanderRx.SUCCESS: print('Walk: {:4d}h {:4d}v Look: {:4d}h {:4d}v {:08b}'.format( crx.walkh, crx.walkv, crx.lookh, crx.lookv, crx.button))
log('Timeout') def scan(self): self.ids = [] self.scan_range(0, 32) self.scan_range(100, 32) if len(self.ids) == 0: log('No devices found') else: log('Scan done') heartbeat = HeartBeat(RED_LED) activity = Activity(GREEN_LED) host_uart = USB_Port() device_uart = UART_Port(device_uart_num, baud=1000000) button = pyb.Switch() pkt = packet.Packet() rsp = packet.Packet() log('Pico Adapter - Bioloid Packet Forwarder') log('Control-C - Quit') log('s - Scan Bus') log('d - Debug - Show Packets') show = Bus.SHOW_NONE while True: heartbeat.process() activity.process() byte = host_uart.read_byte()
self.bus.scan(start_id, num_ids, self.dev_found, None) except BusError: log('Timeout') def scan(self): self.ids = [] self.scan_range(0, 32) self.scan_range(100, 32) if len(self.ids) == 0: log('No devices found') else: log('Scan done') host_uart = USB_Port() device_uart = UART_Port(device_uart_num, baud=1000000) show = Bus.SHOW_NONE dev = IO_Adapter(host_uart, show=show) button = pyb.Switch() rsp = packet.Packet() log('Pico IO Adapter - Bioloid Packet Forwarder') log('Control-C - Quit') log('s - Scan Bus') log('d - Debug - Show Packets') last_update = 0 heartbeat = HeartBeat(RED_LED)
def pyboard_main(): from stm_uart_port import UART_Port serial_port = UART_Port(6, 1000000) bus = Bus(serial_port, show_packets=False) test(bus)