Private
Public Access
2
0

uart: add function mraa_uart_get_dev_path

Used for getting the path to the character device under linux for uart
device. i.e. "/dev/ttyS0"

Adds paths to existing platforms.
Closes #84

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Thomas Ingleby
2015-01-20 15:10:47 +00:00
parent ed4c68eba1
commit 9cfbc87924
11 changed files with 83 additions and 0 deletions

View File

@@ -83,6 +83,7 @@ mraa_uart_init(int index)
memset(dev, 0, sizeof(struct _uart));
dev->index = index;
dev->path = plat->uart_dev[index].device_path;
if (advance_func->uart_init_post != NULL) {
mraa_result_t ret = advance_func->uart_init_post(dev);
if (ret != MRAA_SUCCESS) {
@@ -93,3 +94,17 @@ mraa_uart_init(int index)
return dev;
}
char*
mraa_uart_get_dev_path(mraa_uart_context dev)
{
if (dev == NULL) {
syslog(LOG_ERR, "uart: get_device_path failed, context is NULL");
return "ERROR:CONTEXT_IS_NULL";
}
if (dev->path == NULL) {
syslog(LOG_ERR, "uart: device path undefined");
return "ERROR:PATH_NOT_SET";
}
return dev->path;
}