Private
Public Access
2
0

uart: add capability to check if data can be read from device

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Jon Trulson
2015-04-29 16:13:07 -06:00
committed by Thomas Ingleby
parent cf14939cca
commit c30457e434
3 changed files with 60 additions and 0 deletions

View File

@@ -113,6 +113,15 @@ int mraa_uart_read(mraa_uart_context dev, char *buf, size_t len);
*/
int mraa_uart_write(mraa_uart_context dev, char *buf, size_t len);
/**
* Check to see if data is available on the device for reading
*
* @param dev uart context
* @param millis number of milliseconds to wait, or 0 to return immediately
* @return 1 if there is data available to read, 0 otherwise
*/
mraa_boolean_t
mraa_uart_data_available(mraa_uart_context dev, unsigned int millis);
#ifdef __cplusplus
}

View File

@@ -128,6 +128,21 @@ class Uart
return mraa_uart_write(m_uart, buf, len);
}
/**
* Check to see if data is available on the device for reading
*
* @param millis number of milliseconds to wait, or 0 to return immediately
* @return true if there is data available to read, false otherwise
*/
bool
dataAvailable(unsigned int millis=0)
{
if (mraa_uart_data_available(m_uart, millis))
return true;
else
return false;
}
private:
mraa_uart_context m_uart;
};