Beispiel #1
0
    def __init__(self, device=None, verbose=0):
        """
        Sets up a new GreatFET-backed Facedancer (GreatDancer) application.

        device: The GreatFET device that will act as our GreatDancer.
        verbose: The verbosity level of the given application.
        """

        import greatfet

        if device is None:
            device = greatfet.GreatFET()

        FacedancerApp.__init__(self, device, verbose)
        self.connected_device = None
        self.vendor_requests = greatfet.protocol.vendor_requests

        # Initialize a dictionary that will store the last setup
        # whether each endpoint is currently stalled.
        self.endpoint_stalled = {}
        for i in range(self.SUPPORTED_ENDPOINTS):
            self.endpoint_stalled[i] = False

        # Store a reference to the device's active configuration,
        # which we'll use to know which endpoints we'll need to check
        # for data transfer readiness.
        self.configuration = None
Beispiel #2
0
    def __init__(self, device=None, verbose=0, quirks=None):
        """
        Sets up a new GreatFET-backed Facedancer (GreatDancer) application.

        device: The GreatFET device that will act as our GreatDancer.
        verbose: The verbosity level of the given application.
        """

        import greatfet

        if device is None:
            device = greatfet.GreatFET()

        self.device = device

        self.device.comms.get_exclusive_access()

        FacedancerApp.__init__(self, device, verbose)
        self.connected_device = None

        # Grab the raw API object from the GreatFET object.
        # This has the low-level RPCs used for raw USB control.
        self.api = self.device.apis.greatdancer

        # Initialize a dictionary that will store the last setup
        # whether each endpoint is currently stalled.
        self.endpoint_stalled = {}
        for i in range(self.SUPPORTED_ENDPOINTS):
            self.endpoint_stalled[i] = False

        # Assume a max packet size of 64 until configured otherwise.
        self.max_ep0_packet_size = 64

        # Start off by assuming we're not waiting for an OUT control transfer's
        # data stage.  # See _handle_setup_complete_on_endpoint for details.
        self.pending_control_request = None

        # Store a reference to the device's active configuration,
        # which we'll use to know which endpoints we'll need to check
        # for data transfer readiness.
        self.configuration = None

        #
        # Store our list of quirks to handle.
        #
        if quirks:
            self.quirks = quirks
        else:
            self.quirks = []
    def appropriate_for_environment(cls, backend_name):
        """
        Determines if the current environment seems appropriate
        for using the GreatDancer backend.
        """

        # Check: if we have a backend name other than greatfet,
        # the user is trying to use something else. Abort!
        if backend_name and backend_name != "greatfet":
            return False

        # If we're not explicitly trying to use something else,
        # see if there's a connected GreatFET.
        try:
            gf = greatfet.GreatFET()
            return True
        except:
            return False
Beispiel #4
0
    def set_up_greatfet(self):
        """ Connects to our GreatFET, but does not yet start sampling. """

        import greatfet

        self.device = greatfet.GreatFET()

        # Load the Rhododendron firmware loadable into memory.
        try:
            data = read_rhododendron_m0_loadable()
        except (OSError, TypeError):
            raise

        # Bring our Rhododendron board online; and capture communication parameters.
        self.buffer_size, self.endpoint = self.device.apis.usb_analyzer.initialize(
            self.capture_speed, timeout=10000, comms_timeout=10000)

        # Start the m0 loadable for Rhododendron.
        self.device.m0.run_loadable(data)
Beispiel #5
0
    def __init__(self, verbose=0, quirks=[], autoconnect=True, device=None):
        """
        Sets up a GreatFET-based host connection.
        """

        import greatfet

        if device is None:
            device = greatfet.GreatFET()

        # Store our input args.
        # TODO: pull into base class
        self.device = device
        self.verbose = verbose

        # Grab a reference to our protocol definitions.
        self.vendor_requests = greatfet.protocol.vendor_requests

        if autoconnect:
            self.connect()
Beispiel #6
0
    def appropriate_for_environment(cls, backend_name):
        """
        Determines if the current environment seems appropriate
        for using the GreatDancer backend.
        """

        # Check: if we have a backend name other than greatfet,
        # the user is trying to use something else. Abort!
        if backend_name and backend_name != "greatfet":
            return False

        # If we're not explicitly trying to use something else,
        # see if there's a connected GreatFET.
        try:
            import greatfet
            gf = greatfet.GreatFET()
            return True
        except ImportError:
            sys.stderr.write("NOTE: Skipping GreatFET-based devices, as the greatfet python module isn't installed.\n")
            return False
        except:
            return False
Beispiel #7
0
    def __init__(self, device=None, verbose=0, quirks=None):
        """
        Sets up a new GreatFET-backed Facedancer (GreatDancer) application.

        device: The GreatFET device that will act as our GreatDancer.
        verbose: The verbosity level of the given application.
        """

        import greatfet

        if device is None:
            device = greatfet.GreatFET()

        FacedancerApp.__init__(self, device, verbose)
        self.connected_device = None
        self.vendor_requests = greatfet.protocol.vendor_requests

        # Initialize a dictionary that will store the last setup
        # whether each endpoint is currently stalled.
        self.endpoint_stalled = {}
        for i in range(self.SUPPORTED_ENDPOINTS):
            self.endpoint_stalled[i] = False

        # Start off by assuming we're not waiting for an OUT control transfer's
        # data stage.  # See _handle_setup_complete_on_endpoint for details.
        self.pending_control_packet_data = None

        # Store a reference to the device's active configuration,
        # which we'll use to know which endpoints we'll need to check
        # for data transfer readiness.
        self.configuration = None

        #
        # Store our list of quirks to handle.
        #
        if quirks:
            self.quirks = quirks
        else:
            self.quirks = []