mirror of
https://github.com/eclipse/upm.git
synced 2025-03-28 03:10:06 +03:00
ublox6: 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:
parent
fec3f22765
commit
809292630f
@ -27,23 +27,8 @@
|
|||||||
|
|
||||||
var GPSSensor = require('jsupm_ublox6');
|
var GPSSensor = require('jsupm_ublox6');
|
||||||
|
|
||||||
// Instantiate a Ublox6 GPS device on uart 0 (/dev/ttyS0). This
|
// Instantiate a Ublox6 GPS device on uart 0.
|
||||||
// works for the galileo G2.
|
var myGPSSensor = new GPSSensor.Ublox6(0);
|
||||||
|
|
||||||
// The Edison uses a different serial port, /dev/ttyMFD1, so if you
|
|
||||||
// are using this example on an Edison board, specify the proper
|
|
||||||
// port on the command line, eg: 'node ublox6.js /dev/ttyMFD1'
|
|
||||||
// process.argv.length contains all command-line strings
|
|
||||||
// argument 0 is "node"
|
|
||||||
// argument 1 is "ublox6.js"
|
|
||||||
// argument 2, if it exists, will be the override port,
|
|
||||||
// such as /dev/ttyMFD1 on Edison
|
|
||||||
|
|
||||||
var defaultPort = "/dev/ttyS0";
|
|
||||||
if (process.argv.length > 2)
|
|
||||||
defaultPort = process.argv[2];
|
|
||||||
|
|
||||||
var myGPSSensor = new GPSSensor.Ublox6(0, defaultPort);
|
|
||||||
|
|
||||||
if (!myGPSSensor.setupTty(GPSSensor.int_B9600))
|
if (!myGPSSensor.setupTty(GPSSensor.int_B9600))
|
||||||
{
|
{
|
||||||
|
@ -44,18 +44,8 @@ int main (int argc, char **argv)
|
|||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
// Instantiate a Ublox6 GPS device on uart 0 (/dev/ttyS0). This
|
// Instantiate a Ublox6 GPS device on uart 0.
|
||||||
// works for the galileo G2.
|
upm::Ublox6* nmea = new upm::Ublox6(0);
|
||||||
|
|
||||||
// The Edison uses a different serial port, /dev/ttyMFD1, so if you
|
|
||||||
// are using this example on an Edison board, specify the proper
|
|
||||||
// port on the command line, eg: './ublox6-example /dev/ttyMFD1'
|
|
||||||
|
|
||||||
const char *defaultPort = "/dev/ttyS0";
|
|
||||||
if (argc > 1)
|
|
||||||
defaultPort = argv[1];
|
|
||||||
|
|
||||||
upm::Ublox6* nmea = new upm::Ublox6(0, defaultPort);
|
|
||||||
|
|
||||||
// make sure port is initialized properly. 9600 baud is the default.
|
// make sure port is initialized properly. 9600 baud is the default.
|
||||||
if (!nmea->setupTty(B9600))
|
if (!nmea->setupTty(B9600))
|
||||||
|
@ -29,10 +29,9 @@
|
|||||||
using namespace upm;
|
using namespace upm;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Ublox6::Ublox6(int uart, const char *tty) :
|
Ublox6::Ublox6(int uart)
|
||||||
m_ttyFd(-1)
|
|
||||||
{
|
{
|
||||||
mraa_init();
|
m_ttyFd = -1;
|
||||||
|
|
||||||
if ( !(m_uart = mraa_uart_init(uart)) )
|
if ( !(m_uart = mraa_uart_init(uart)) )
|
||||||
{
|
{
|
||||||
@ -40,10 +39,19 @@ Ublox6::Ublox6(int uart, const char *tty) :
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now open the tty
|
// This requires a recent MRAA (1/2015)
|
||||||
if ( (m_ttyFd = open(tty, O_RDWR)) == -1)
|
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;
|
<< strerror(errno) << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,8 @@ namespace upm {
|
|||||||
* U-BLOX 6 GPS module constructor
|
* U-BLOX 6 GPS module constructor
|
||||||
*
|
*
|
||||||
* @param uart defualt uart to use (0 or 1)
|
* @param uart defualt uart to use (0 or 1)
|
||||||
* @param tty tty device to use
|
|
||||||
*/
|
*/
|
||||||
Ublox6(int uart, const char *tty);
|
Ublox6(int uart);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* U-BLOX 6 GPS module Destructor
|
* U-BLOX 6 GPS module Destructor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user