From 87bbaaa43d885349bd18dd0324c98a13ed2dff22 Mon Sep 17 00:00:00 2001
From: Martino Facchin <m.facchin@arduino.cc>
Date: Wed, 16 Sep 2015 14:56:21 +0200
Subject: [PATCH] fix PUSB_getInterface return value

---
 cores/arduino/USB/PluggableUSB.cpp | 2 +-
 cores/arduino/USB/USBCore.cpp      | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/cores/arduino/USB/PluggableUSB.cpp b/cores/arduino/USB/PluggableUSB.cpp
index 84d781d8..1a15dfa4 100644
--- a/cores/arduino/USB/PluggableUSB.cpp
+++ b/cores/arduino/USB/PluggableUSB.cpp
@@ -40,7 +40,7 @@ int PUSB_GetInterface(uint8_t* interfaceNum)
 	int ret = 0;
 	PUSBListNode* node = rootNode;
 	for (uint8_t i=0; i<modules_count; i++) {
-		ret = node->cb->getInterface(interfaceNum);
+		ret += node->cb->getInterface(interfaceNum);
 		node = node->next;
 	}
 	return ret;
diff --git a/cores/arduino/USB/USBCore.cpp b/cores/arduino/USB/USBCore.cpp
index 171fe389..ddc20146 100644
--- a/cores/arduino/USB/USBCore.cpp
+++ b/cores/arduino/USB/USBCore.cpp
@@ -156,6 +156,8 @@ uint32_t USBDeviceClass::sendConfiguration(uint32_t maxlen)
 		return true;
 	}
 
+	total = 0;
+
 	packMessages(true);
 	sendControl(&config, sizeof(ConfigDescriptor));
 	SendInterfaces(&total);
-- 
GitLab