From 980dfce80ed5ee5f2244aaf434d0ef29a5e6babc Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 11 Oct 2016 13:58:39 +0100 Subject: [PATCH] mraa.c: return MRAA_SUCCESS when trying to call mraa_add_subplatform twice If we already have a subplatform present with the same type, return success when trying to add it again. We don't check that the tty is the same because that is hidden inside the t_firmata* structure but we should do at some point Signed-off-by: Brendan Le Foll --- src/mraa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mraa.c b/src/mraa.c index c3050f4..707f1c5 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -1027,8 +1027,12 @@ mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev) #if defined(FIRMATA) if (subplatformtype == MRAA_GENERIC_FIRMATA) { if (plat->sub_platform != NULL) { - syslog(LOG_NOTICE, "mraa: Failed to add firmata subplatform"); - return MRAA_ERROR_INVALID_PARAMETER; + if (plat->sub_platform->platform_type == subplatformtype) { + syslog(LOG_NOTICE, "mraa: Firmata subplatform already present"); + return MRAA_SUCCESS; + } + syslog(LOG_NOTICE, "mraa: We don't support multiple firmata subplatforms!"); + return MRAA_ERROR_FEATURE_NOT_SUPPORTED; } if (mraa_firmata_platform(plat, uart_dev) == MRAA_GENERIC_FIRMATA) { syslog(LOG_NOTICE, "mraa: Added firmata subplatform");