Skip to content

Commit

Permalink
updated vendor requests for new comms api
Browse files Browse the repository at this point in the history
  • Loading branch information
mossmann authored and ktemkin committed Dec 14, 2018
1 parent df3c652 commit 3276c22
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions facedancer/backends/GreatDancerHostApp.py
Expand Up @@ -131,7 +131,7 @@ def connect(self):
"""
Sets up our host to talk to the device, including turning on VBUS.
"""
self.device.vendor_request_out(self.vendor_requests.USBHOST_CONNECT)
self.device.comms._vendor_request_out(self.vendor_requests.USBHOST_CONNECT)


def bus_reset(self, delay=0.500):
Expand All @@ -146,7 +146,7 @@ def bus_reset(self, delay=0.500):
# Note: we need to wait a reset delay before and after the bus reset.
# This allows the host to initialize _and_ then allows the device to settle.
time.sleep(delay)
self.device.vendor_request_out(self.vendor_requests.USBHOST_BUS_RESET)
self.device.comms._vendor_request_out(self.vendor_requests.USBHOST_BUS_RESET)
time.sleep(delay)


Expand All @@ -168,7 +168,7 @@ def _fetch_status_register(self, register_number):
Fetches a status register from the GreatDacner, and returns it
as an integer.
"""
raw_status = self.device.vendor_request_in(self.vendor_requests.USBHOST_GET_STATUS, index=register_number, length=4)
raw_status = self.device.comms._vendor_request_in(self.vendor_requests.USBHOST_GET_STATUS, index=register_number, length=4)
return self._decode_usb_register(raw_status)


Expand Down Expand Up @@ -306,7 +306,7 @@ def set_up_endpoint(self, endpoint_address_or_object, endpoint_type=None, max_pa
# Issue the configuration packet.
packet = struct.pack("<BBBBBHB", endpoint_schedule, device_address, endpoint_address,
endpoint_speed, is_control_endpoint, max_packet_size, handle_data_toggle)
self.device.vendor_request_out(self.vendor_requests.USBHOST_SET_UP_ENDPOINT, data=packet)
self.device.comms._vendor_request_out(self.vendor_requests.USBHOST_SET_UP_ENDPOINT, data=packet)


def initialize_control_endpoint(self, device_address=None, device_speed=None, max_packet_size=None):
Expand Down Expand Up @@ -347,7 +347,7 @@ def send_on_endpoint(self, endpoint_number, data, is_setup=False,
# Issue the actual send itself.
# TODO: validate length

self.device.vendor_request_out(self.vendor_requests.USBHOST_SEND_ON_ENDPOINT,
self.device.comms._vendor_request_out(self.vendor_requests.USBHOST_SEND_ON_ENDPOINT,
index=endpoint_number, value=(data_packet_pid << 8) | pid_token,
data=data)

Expand Down Expand Up @@ -382,7 +382,7 @@ def read_from_endpoint(self, endpoint_number, expected_read_size=64, data_packet
"""

# Start the request...
self.device.vendor_request_out(self.vendor_requests.USBHOST_START_NONBLOCKING_READ,
self.device.comms._vendor_request_out(self.vendor_requests.USBHOST_START_NONBLOCKING_READ,
index=(data_packet_pid << 8) | endpoint_number, value=expected_read_size)

# ... and if we're blocking, also finish it.
Expand All @@ -401,7 +401,7 @@ def read_from_endpoint(self, endpoint_number, expected_read_size=64, data_packet
raise IOError("Stalled!")

# Figure out how muhc to read.
raw_length = self.device.vendor_request_in(self.vendor_requests.USBHOST_GET_NONBLOCKING_LENGTH,
raw_length = self.device.comms._vendor_request_in(self.vendor_requests.USBHOST_GET_NONBLOCKING_LENGTH,
index=endpoint_number, length=4)
length = self._decode_usb_register(raw_length)

Expand All @@ -413,7 +413,7 @@ def read_from_endpoint(self, endpoint_number, expected_read_size=64, data_packet
return b''

# Otherwise, read the data from the endpoint and return it.
data = self.device.vendor_request_in(self.vendor_requests.USBHOST_FINISH_NONBLOCKING_READ,
data = self.device.comms._vendor_request_in(self.vendor_requests.USBHOST_FINISH_NONBLOCKING_READ,
index=endpoint_number, length=length)
return data.tostring()

0 comments on commit 3276c22

Please sign in to comment.