Skip to content

Commit

Permalink
Do not empty the ep pool, use set difference to have unique ep addr
Browse files Browse the repository at this point in the history
  • Loading branch information
kauwua committed Jul 20, 2024
1 parent 2a1326e commit 03d38a0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions facedancer/backends/hydradancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def init(self):
raise HydradancerBoardFatalError(
f"Could not get handle on Hydradancer events endpoint (EP {self.EP_POLL_NUMBER})")

self.endpoints_pool = list(self.ep_in.keys())
self.endpoints_pool = set(self.ep_in.keys())

# wait until the board is ready, for instance if a disconnect was previously issued
self.wait_board_ready()
Expand All @@ -498,7 +498,6 @@ def disconnect(self):
usb.util.dispose_resources(self.device)

# Reset state just in case
self.endpoints_pool = list(self.ep_in.keys())
self.hydradancer_status["ep_in_status"] = 0x00
self.hydradancer_status["ep_out_status"] = 0x00
self.hydradancer_status["ep_in_nak"] = 0x00
Expand Down Expand Up @@ -564,7 +563,7 @@ def set_endpoint_mapping(self, ep_num):
raise HydradancerBoardFatalError(
f"All endpoints are already in use")

self.endpoints_mapping[ep_num] = self.endpoints_pool.pop()
self.endpoints_mapping[ep_num] = list(self.endpoints_pool - set(self.endpoints_mapping.values()))[0]
self.reverse_endpoints_mapping[self.endpoints_mapping[ep_num]] = ep_num
try:
self.device.ctrl_transfer(CTRL_TYPE_VENDOR | CTRL_RECIPIENT_DEVICE | CTRL_OUT,
Expand Down

0 comments on commit 03d38a0

Please sign in to comment.