Problem:
calling the get_focus_mode() method with Birddog X1 camera results in a KeyError exception
Diagnosis:
The Birddog X1 does not currently implement the GETFOCUSMODE (0x04 0x38) INQUIRY. Instead it returns a generic reply. Doing a dict lookup based on the last byte of the reply (which seems to be an ascii 'A') causes a KeyError.
Possible fix:
Adding a try/except around the dict index makes the code more robust and avoids the problem
def get_focus_mode(self) -> str:
""":return: either 'auto' or 'manual'"""
modes = {2: 'auto', 3: 'manual'}
response = self._send_command('04 38', query=True)
try:
mode = modes[response[-1]]
except KeyError:
mode = 'unknown'
return mode