-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Structure code and bug fix #15
Conversation
…eyboard Interrupt.
Structure code and bug fix
…iles and organize them into a csv file.
Thanks for fixing the issue. It is pretty obvious now what was going on with the FIFO blocking the logger. The separation into functions and cleanup of some old code, also make sense. I do have one request tho. Instead of config parsers and config file, could you just make it use I really do not like having config files, or extra dependencies (no matter how small). Something like this: def main():
...
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--crc", type=bool, help="Enable CRC checks", default=False)
parser.add_argument("--dev", type=str, help="....", default="")
args = parser.parse_args()
...
crc_checker = None # alternatively lambda x: True
if args.crc:
import crc
crc_checker = lambda_or_something
# use args.dev to find specific device (i.e. by USB path/bus/device id) You can make --crc default to False, or auto-detect by trying to import (I think we might be already doing this). For booleans on command line I usually use a helper like this: def str2bool(v: Union[str, bool], default_on_error: bool) -> bool:
if isinstance(v, bool):
return v
vl = v.lower()
if vl in ("yes", "true", "t", "1"):
return True
if vl in ("no", "false", "f", "0"):
return False
# raise ValueError("str2bool argument type must be true or false, found {v}")
return default_on_error Then in argparse, I use it like this: parser.add_argument("--crc", type=str2bool, help="Enable CRC checks", default=True) Then can do |
@baryluk I understand your concerns, I have substituted configparser for argparse. |
Also, I suspect that for FNB58 the HID interface, even though it works (more or less), might not be the correct one. The set of interfaces on FNB58 is as follows:
I suspect Interface 2 might be the correct one, and hence why CRC does not work for FNB58. However, simply swapping the interfaces is not sufficient to get it to work and I do not know what commands to send to the device for that interface. |
Otherwise doing set_configuration will error out with: usb.core.USBError: [Errno 16] Resource busy It should be possible to do a target set_configuration which only targets the HID interface we care about, but currently we either target all or 0th one, but HID one might be for example 3rd one. Fixes: #17 Fixes: #15
Separated code into functions.
Added configuration file to enable/disable crc check, which does not work for all devices (left it disabled by default).
The program now exhausts all reads before exiting the program when a Keyboard Interrupt occurs.
This changes help with issues #12 and #7.