mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
Code for MHZ16 sensor was using only default UART configuration
with **mraa_uart_init()** function this proposal enables to use also **mraa_uart_init_raw()** function to choose another path for UART Signed-off-by: g-vidal <gerard.vidal@ens-lyon.fr>
This commit is contained in:
parent
ad15b27cb1
commit
99bc6611a9
@ -37,12 +37,24 @@ MHZ16::MHZ16(int uart)
|
|||||||
{
|
{
|
||||||
m_ttyFd = -1;
|
m_ttyFd = -1;
|
||||||
|
|
||||||
if ( !(m_uart = mraa_uart_init(uart)) )
|
if (uart == 99)
|
||||||
{
|
{
|
||||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
if ( !(m_uart = mraa_uart_init_raw(path)) )
|
||||||
": mraa_uart_init() failed");
|
{
|
||||||
return;
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
}
|
": mraa_uart_init_raw() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !(m_uart = mraa_uart_init(uart)) )
|
||||||
|
{
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_uart_init() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This requires a recent MRAA (1/2015)
|
// This requires a recent MRAA (1/2015)
|
||||||
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
const char *devPath = mraa_uart_get_dev_path(m_uart);
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <mraa/uart.h>
|
#include <mraa/uart.h>
|
||||||
|
|
||||||
const int MHZ16_DEFAULT_UART = 0;
|
const int MHZ16_DEFAULT_UART = 0;
|
||||||
|
const char * MHZ16_DEFAULT_UART_PATH = "/dev/ttyS0";
|
||||||
|
|
||||||
// protocol start and end codes
|
// protocol start and end codes
|
||||||
const uint8_t MHZ16_START = 0x7e;
|
const uint8_t MHZ16_START = 0x7e;
|
||||||
@ -80,9 +81,10 @@ namespace upm {
|
|||||||
/**
|
/**
|
||||||
* MHZ16 constructor
|
* MHZ16 constructor
|
||||||
*
|
*
|
||||||
* @param uart Default UART to use (0 or 1)
|
* @param uart Default UART to use (0 or 1 or 99) 0 and 1 are default standard devices
|
||||||
|
* @param path Default PATH to device choose uart=99 to select path instead of standard device
|
||||||
*/
|
*/
|
||||||
MHZ16(int uart);
|
MHZ16(int uart, char * path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MHZ16 destructor
|
* MHZ16 destructor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user