From 0409f985b5b65edbd989a7eb08845994c3958456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=BCller?= Date: Sun, 18 Apr 2021 16:50:03 +0200 Subject: [PATCH] Don't count interfaces with alternate settings multiple times --- usb_protocol/emitters/descriptors/standard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb_protocol/emitters/descriptors/standard.py b/usb_protocol/emitters/descriptors/standard.py index 859bbd1..b3942f1 100644 --- a/usb_protocol/emitters/descriptors/standard.py +++ b/usb_protocol/emitters/descriptors/standard.py @@ -129,8 +129,8 @@ class ConfigurationDescriptorEmitter(ComplexDescriptorEmitter): def _pre_emit(self): - # Count our interfaces. - self.bNumInterfaces = self._type_counts[StandardDescriptorNumbers.INTERFACE] + # Count our interfaces. Alternate settings of the same interface do not count multiple times. + self.bNumInterfaces = len(set([subordinate[2] for subordinate in self._subordinates if (subordinate[1] == StandardDescriptorNumbers.INTERFACE)])) # Figure out our total length. subordinate_length = sum(len(sub) for sub in self._subordinates)