dell / libsmbios

library for interacting with Dell SMBIOS tables
Other
190 stars 39 forks source link

Don't abort dumping tokens on first error #74

Closed marmistrz closed 5 years ago

marmistrz commented 5 years ago

Closes #55. Closes #56.

I can't get decent error messages.

  Token: 0x007d - LCD Brightness (Value)
  value: token query failed: b'Low level SMI call failed.\n\xe0\xc0\xe0h\x7fU'
   Desc: When Mobile Power Management is Enabled, the system will force the LCD 
         brightness to the value specified in this field. This attribute require
         s special handling.

Please confirm if it's a bug in smbios_token.py, if yes: I'll leave it as it is.

Btw. I fixed an awful StopIteration message:

$ sudo smbios-token-ctl -i 0x0343        
================================================================================
  Token: 0x0343 - Primary Battery Charge Configuration (Custom Charge)
  value: bool = true
   Desc: The battery will start and stop charging based on user input
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/libsmbios_c/smbios_token.py", line 134, in __iter__
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/smbios-token-ctl", line 470, in <module>
    sys.exit( main() )
  File "/usr/bin/smbios-token-ctl", line 377, in main
    dumpTokens(tokenTable, tokenXlator, options)
  File "/usr/bin/smbios-token-ctl", line 213, in dumpTokens
    for token in tokenTable:
RuntimeError: generator raised StopIteration
superm1 commented 5 years ago

The kernel filters some requests (and expects you to use the proper kernel interface for them). This is one of those cases. When iterating tokens the ones the kernel has like that are probably just worth automatically skipping.

https://github.com/torvalds/linux/blob/master/drivers/platform/x86/dell-smbios-base.c#L74

marmistrz commented 5 years ago

@superm1 what I mean is that the exception message has some garbage after the \n.

  value: token query failed: b'Low level SMI call failed.\n\xe0\xc0\xe0h\x7fU'

What I'd expect instead is:

  value: token query failed: Low level SMI call failed.
superm1 commented 5 years ago

I agree that doesn't look right, some problem in the string length handling on errors probably.