Private
Public Access
2
0

mraa: add mraa_remove_subplatform call

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-04-22 09:38:30 +01:00
parent 6d8ec87e0e
commit e961558fd2
3 changed files with 34 additions and 0 deletions

View File

@@ -284,6 +284,15 @@ int mraa_get_sub_platform_index(int pin_or_bus_id);
*/
mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev);
/**
* Remove a mraa subplatform
*
* @param subplatform type
*
* @return mraa_result indicating success
*/
mraa_result_t mraa_remove_subplatform(mraa_platform_t subplatformtype);
#ifdef __cplusplus
}
#endif

View File

@@ -303,4 +303,10 @@ addSubplatform(Platform subplatformtype, std::string uart_dev)
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
}
inline Result
removeSubplatform(Platform subplatformtype)
{
return (Result) mraa_remove_subplatform((mraa_platform_t) subplatformtype);
}
}

View File

@@ -982,6 +982,9 @@ mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev)
{
#if defined(FIRMATA)
if (subplatformtype == MRAA_GENERIC_FIRMATA) {
if (plat->sub_platform != NULL) {
return MRAA_ERROR_INVALID_PARAMETER;
}
if (mraa_firmata_platform(plat, uart_dev) == MRAA_GENERIC_FIRMATA) {
syslog(LOG_NOTICE, "mraa: Added firmata subplatform");
return MRAA_SUCCESS;
@@ -993,6 +996,22 @@ mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev)
return MRAA_ERROR_INVALID_PARAMETER;
}
mraa_result_t
mraa_remove_subplatform(mraa_platform_t subplatformtype)
{
#if defined(FIRMATA)
if (subplatformtype == MRAA_GENERIC_FIRMATA) {
if (plat == NULL || plat->sub_platform == NULL) {
return MRAA_ERROR_INVALID_PARAMETER;
}
free(plat->sub_platform->adv_func);
free(plat->sub_platform->pins);
free(plat->sub_platform);
}
#endif
return MRAA_ERROR_INVALID_PARAMETER;
}
#if defined(IMRAA)
mraa_result_t
mraa_add_from_lockfile(const char* imraa_lock_file)