mraa: add mraa_remove_subplatform call
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -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);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -303,4 +303,10 @@ addSubplatform(Platform subplatformtype, std::string uart_dev)
|
|||||||
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/mraa.c
19
src/mraa.c
@@ -982,6 +982,9 @@ mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev)
|
|||||||
{
|
{
|
||||||
#if defined(FIRMATA)
|
#if defined(FIRMATA)
|
||||||
if (subplatformtype == MRAA_GENERIC_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) {
|
if (mraa_firmata_platform(plat, uart_dev) == MRAA_GENERIC_FIRMATA) {
|
||||||
syslog(LOG_NOTICE, "mraa: Added firmata subplatform");
|
syslog(LOG_NOTICE, "mraa: Added firmata subplatform");
|
||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
@@ -993,6 +996,22 @@ mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev)
|
|||||||
return MRAA_ERROR_INVALID_PARAMETER;
|
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)
|
#if defined(IMRAA)
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
mraa_add_from_lockfile(const char* imraa_lock_file)
|
mraa_add_from_lockfile(const char* imraa_lock_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user