wt5001: switch to using new mraa_uart_get_dev_path()

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson
2015-01-21 17:41:35 -07:00
committed by Mihai Tudor Panu
parent 809292630f
commit 328b7638ad
3 changed files with 17 additions and 24 deletions

View File

@ -31,10 +31,9 @@ using namespace std;
static const int defaultDelay = 100; // max wait time for read
WT5001::WT5001(int uart, const char *tty) :
m_ttyFd(-1)
WT5001::WT5001(int uart)
{
mraa_init();
m_ttyFd = -1;
if ( !(m_uart = mraa_uart_init(uart)) )
{
@ -42,10 +41,19 @@ WT5001::WT5001(int uart, const char *tty) :
return;
}
// now open the tty
if ( (m_ttyFd = open(tty, O_RDWR)) == -1)
// This requires a recent MRAA (1/2015)
char *devPath = mraa_uart_get_dev_path(m_uart);
if (!devPath)
{
cerr << __FUNCTION__ << ": open of " << tty << " failed: "
cerr << __FUNCTION__ << ": mraa_uart_get_dev_path() failed" << endl;
return;
}
// now open the tty
if ( (m_ttyFd = open(devPath, O_RDWR)) == -1)
{
cerr << __FUNCTION__ << ": open of " << devPath << " failed: "
<< strerror(errno) << endl;
return;
}

View File

@ -110,9 +110,8 @@ namespace upm {
* WT5001 Serial MP3 module constructor
*
* @param uart default uart to use (0 or 1)
* @param tty tty device to use
*/
WT5001(int uart, const char *tty);
WT5001(int uart);
/**
* WT5001 Serial MP3 module Destructor