Add request_remaining("name") that returns unallocated pins.

Improve error reporting on request_all().
This commit is contained in:
Jevin Sweval 2022-05-21 13:46:01 -07:00
parent a426ec9e2f
commit 0b9ffb6adb
1 changed files with 15 additions and 1 deletions

View File

@ -230,7 +230,18 @@ class ConstraintManager:
except ConstraintError: except ConstraintError:
break break
if not len(r): if not len(r):
raise ValueError raise ValueError(f"Could not request some pin(s) named '{name}'")
return Cat(r)
def request_remaining(self, name):
r = []
while True:
try:
r.append(self.request(name))
except ConstraintError:
break
if not len(r):
raise ValueError(f"Could not request any pins named '{name}'")
return Cat(r) return Cat(r)
def lookup_request(self, name, number=None, loose=False): def lookup_request(self, name, number=None, loose=False):
@ -321,6 +332,9 @@ class GenericPlatform:
def request_all(self, *args, **kwargs): def request_all(self, *args, **kwargs):
return self.constraint_manager.request_all(*args, **kwargs) return self.constraint_manager.request_all(*args, **kwargs)
def request_remaining(self, *args, **kwargs):
return self.constraint_manager.request_remaining(*args, **kwargs)
def lookup_request(self, *args, **kwargs): def lookup_request(self, *args, **kwargs):
return self.constraint_manager.lookup_request(*args, **kwargs) return self.constraint_manager.lookup_request(*args, **kwargs)