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:
@@ -149,6 +149,7 @@ typedef struct {
|
||||
unsigned int index; /**< ID as exposed in the system */
|
||||
int rx; /**< uart rx */
|
||||
int tx; /**< uart tx */
|
||||
char* device_path; /**< To store "/dev/ttyS1" for example */
|
||||
/*@}*/
|
||||
} mraa_uart_dev_t;
|
||||
|
||||
|
||||
@@ -54,6 +54,15 @@ typedef struct _uart* mraa_uart_context;
|
||||
*/
|
||||
mraa_uart_context mraa_uart_init(int uart);
|
||||
|
||||
/**
|
||||
* Get Char pointer with tty device path within Linux
|
||||
* For example. Could point to "/dev/ttyS0"
|
||||
*
|
||||
* @param dev uart context
|
||||
* @return char pointer of device path
|
||||
*/
|
||||
char* mraa_uart_get_dev_path(mraa_uart_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -55,6 +55,17 @@ class Uart {
|
||||
~Uart() {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string with tty device path within Linux
|
||||
* For example. Could point to "/dev/ttyS0"
|
||||
*
|
||||
* @return char pointer of device path
|
||||
*/
|
||||
std::string getDevicePath() {
|
||||
std::string ret_val(mraa_uart_get_dev_path(m_uart));
|
||||
return ret_val;
|
||||
}
|
||||
private:
|
||||
mraa_uart_context m_uart;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user