python-validity/proto97/blobs.py
Marco Trevisan (Treviño) 4b5dd81ec2 proto97: Make loading blobs dynamically dependent on opened USB device
So we can support both 90 and 97 together
2020-06-11 14:08:59 +02:00

27 lines
716 B
Python

from enum import Enum, auto
class Blobs(Enum):
init_hardcoded = auto()
init_hardcoded_clean_slate = auto()
reset_blob = auto()
db_write_enable = auto()
identify_prg = auto()
enroll_prg = auto()
calibrate_prg = auto()
def __load_blob(blob):
from .usb import usb
if usb.usb_dev().idVendor == 0x138a:
if usb.usb_dev().idProduct == 0x0090:
from . import blobs_90 as blobs
elif usb.usb_dev().idProduct == 0x0097:
from . import blobs_97 as blobs
globals()[blob] = getattr(blobs, blob)
return globals()[blob]
for p in dir(Blobs):
if isinstance(getattr(Blobs, p), Blobs):
globals()[p] = lambda bname=p: __load_blob(bname)