Instead of checking if a command is in a fixed list/tuple (that needs
to be manually updated every time a new command becomes supported),
simply check if the respective handling method for the command exists.
This fixes the bug of the CMD16 handler not being called, and will
prevent similar bugs in the future.
# Handle command.
s = 'ACMD' if self.is_acmd else 'CMD'
self.cmd_str = '%s%d (%s)' % (s, self.cmd, self.cmd_name(self.cmd))
- if self.cmd in (0, 2, 3, 6, 7, 8, 9, 10, 13, 41, 51, 55):
+ if hasattr(self, 'handle_%s%d' % (s.lower(), self.cmd)):
self.state = St['HANDLE_CMD%d' % self.cmd]
else:
self.state = St.HANDLE_CMD999