# Path: tailor/hardware/arduino/protocol/factory.py
# def build(name, **kwargs):
#     try:
#         command = command_lookup[name]
#         name, sig = command_names[command]
#     except KeyError:
#         raise UnhandledPacketType
# 
#     if command in command_names:
#         args = mappp(sig, kwargs)
#         return bytearray([command, args[0]])
# 
#     else:
#         raise Exception
# 
# def parse(handler):
#     while 1:
#         byte = yield
# 
#         if byte in command_names:
#             name, sig = command_names[byte]
#             value0 = yield
#             c = make_container(name, sig, (value0,))
#             handler(c)
# 
#         else:
#             raise UnhandledPacketType


import asyncio
from .protocol.factory import build, parse
# -*- coding: utf-8 -*-



class Board:
    def __init__(self, serial_device=None, wait=2):
        """ Exposes the Firmata API

        :param serial_device: Serial device to use, or None
        :param wait: Time to wait for board to reset.  Uno=2, Leo=0
        """
        self.serial_device = serial_device
        self.sleep_time_until_ready = wait
        self.digital_pin_ports = [0] * 8  # move to autoconfig
        self.started = False

        self.packet_parser = parse(self.handle_packet)
        self.packet_parser.send(None)

# Path: tailor/hardware/arduino/protocol/factory.py
# def build(name, **kwargs):
#     try:
#         command = command_lookup[name]
#         name, sig = command_names[command]
#     except KeyError:
#         raise UnhandledPacketType
# 
#     if command in command_names:
#         args = mappp(sig, kwargs)
#         return bytearray([command, args[0]])
# 
#     else:
#         raise Exception
# 
# def parse(handler):
#     while 1:
#         byte = yield
# 
#         if byte in command_names:
#             name, sig = command_names[byte]
#             value0 = yield
#             c = make_container(name, sig, (value0,))
#             handler(c)
# 
#         else:
#             raise UnhandledPacketType


# Path: tailor/hardware/arduino/board.py
import asyncio
from .protocol.factory import build, parse

# -*- coding: utf-8 -*-



class Board:
    def __init__(self, serial_device=None, wait=2):
        """ Exposes the Firmata API

        :param serial_device: Serial device to use, or None
        :param wait: Time to wait for board to reset.  Uno=2, Leo=0
        """
        self.serial_device = serial_device
        self.sleep_time_until_ready = wait
        self.digital_pin_ports = [0] * 8  # move to autoconfig
        self.started = False

        self.packet_parser = parse(self.handle_packet)
        self.packet_parser.send(None)

        self.packet_factory = build