APM:Libraries
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
HALSITL::UARTDriver Class Reference

#include <UARTDriver.h>

Inheritance diagram for HALSITL::UARTDriver:
[legend]
Collaboration diagram for HALSITL::UARTDriver:
[legend]

Public Member Functions

 UARTDriver (const uint8_t portNumber, SITL_State *sitlState)
 
void begin (uint32_t b)
 
void begin (uint32_t b, uint16_t rxS, uint16_t txS)
 
void end ()
 
void flush ()
 
bool is_initialized ()
 
void set_blocking_writes (bool blocking)
 
bool tx_pending ()
 
uint32_t available () override
 
uint32_t txspace () override
 
int16_t read () override
 
size_t write (uint8_t c)
 
size_t write (const uint8_t *buffer, size_t size)
 
enum flow_control get_flow_control (void)
 
void configure_parity (uint8_t v) override
 
void set_stop_bits (int n) override
 
bool set_unbuffered_writes (bool on) override
 
void _timer_tick (void)
 
uint64_t receive_time_constraint_us (uint16_t nbytes) override
 
- Public Member Functions inherited from AP_HAL::UARTDriver
 UARTDriver ()
 
virtual bool lock_port (uint32_t key)
 
virtual size_t write_locked (const uint8_t *buffer, size_t size, uint32_t key)
 
virtual void set_flow_control (enum flow_control flow_control_setting)
 
virtual bool wait_timeout (uint16_t n, uint32_t timeout_ms)
 
- Public Member Functions inherited from AP_HAL::BetterStream
virtual void printf (const char *,...) FMT_PRINTF(2
 
virtual void virtual void vprintf (const char *, va_list)
 
void print (const char *str)
 
void println (const char *str)
 
size_t write (const char *str)
 

Static Public Member Functions

static UARTDriverfrom (AP_HAL::UARTDriver *uart)
 

Public Attributes

int _fd
 
bool _unbuffered_writes
 

Private Member Functions

void _tcp_start_connection (uint16_t port, bool wait_for_connection)
 
void _uart_start_connection (void)
 
void _check_reconnect ()
 
void _tcp_start_client (const char *address, uint16_t port)
 
void _check_connection (void)
 
bool set_speed (int speed)
 

Static Private Member Functions

static bool _select_check (int)
 
static void _set_nonblocking (int)
 

Private Attributes

uint8_t _portNumber
 
bool _connected = false
 
bool _use_send_recv = false
 
int _listen_fd
 
int _serial_port
 
bool _nonblocking_writes
 
ByteBuffer _readbuffer {16384}
 
ByteBuffer _writebuffer {16384}
 
const char * _uart_path
 
uint32_t _uart_baudrate
 
const char * _tcp_client_addr
 
SITL_State_sitlState
 
uint64_t _receive_timestamp
 

Static Private Attributes

static bool _console
 

Friends

class HALSITL::SITL_State
 

Additional Inherited Members

- Public Types inherited from AP_HAL::UARTDriver
enum  flow_control { FLOW_CONTROL_DISABLE =0, FLOW_CONTROL_ENABLE =1, FLOW_CONTROL_AUTO =2 }
 

Detailed Description

Definition at line 12 of file UARTDriver.h.

Constructor & Destructor Documentation

◆ UARTDriver()

HALSITL::UARTDriver::UARTDriver ( const uint8_t  portNumber,
SITL_State sitlState 
)
inline

Definition at line 16 of file UARTDriver.h.

Member Function Documentation

◆ _check_connection()

void UARTDriver::_check_connection ( void  )
private

Definition at line 373 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ _check_reconnect()

void UARTDriver::_check_reconnect ( void  )
private

Definition at line 438 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ _select_check()

bool UARTDriver::_select_check ( int  fd)
staticprivate

Definition at line 394 of file UARTDriver.cpp.

Referenced by _check_connection(), and _check_reconnect().

Here is the caller graph for this function:

◆ _set_nonblocking()

void UARTDriver::_set_nonblocking ( int  fd)
staticprivate

Definition at line 415 of file UARTDriver.cpp.

Referenced by HALSITL::SITL_State::gps2_pipe(), and HALSITL::SITL_State::gps_pipe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _tcp_start_client()

void UARTDriver::_tcp_start_client ( const char *  address,
uint16_t  port 
)
private

Definition at line 278 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ _tcp_start_connection()

void UARTDriver::_tcp_start_connection ( uint16_t  port,
bool  wait_for_connection 
)
private

Definition at line 187 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ _timer_tick()

void UARTDriver::_timer_tick ( void  )
virtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 448 of file UARTDriver.cpp.

Referenced by _check_reconnect(), and get_flow_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _uart_start_connection()

void UARTDriver::_uart_start_connection ( void  )
private

Definition at line 329 of file UARTDriver.cpp.

Referenced by _check_reconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ available()

uint32_t HALSITL::UARTDriver::available ( )
overridevirtual

Implements AP_HAL::BetterStream.

Referenced by _check_reconnect(), and tx_pending().

Here is the caller graph for this function:

◆ begin() [1/2]

void HALSITL::UARTDriver::begin ( uint32_t  b)
inlinevirtual

Implements AP_HAL::UARTDriver.

Definition at line 29 of file UARTDriver.h.

Here is the call graph for this function:

◆ begin() [2/2]

void HALSITL::UARTDriver::begin ( uint32_t  baud,
uint16_t  rxSpace,
uint16_t  txSpace 
)
virtual

Extended port open method

Allows for both opening with specified buffer sizes, and re-opening to adjust a subset of the port's settings.

Note
Buffer sizes greater than ::_max_buffer_size will be rounded down.
Parameters
baudSelects the speed that the port will be configured to. If zero, the port speed is left unchanged.
rxSpaceSets the receive buffer size for the port. If zero then the buffer size is left unchanged if the port is open, or set to ::_default_rx_buffer_size if it is currently closed.
txSpaceSets the transmit buffer size for the port. If zero then the buffer size is left unchanged if the port is open, or set to ::_default_tx_buffer_size if it is currently closed.

Implements AP_HAL::UARTDriver.

◆ configure_parity()

void HALSITL::UARTDriver::configure_parity ( uint8_t  v)
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 70 of file UART_utils.cpp.

Referenced by get_flow_control().

Here is the caller graph for this function:

◆ end()

void HALSITL::UARTDriver::end ( )
virtual

Implements AP_HAL::UARTDriver.

Referenced by begin().

Here is the caller graph for this function:

◆ flush()

void HALSITL::UARTDriver::flush ( )
virtual

Implements AP_HAL::UARTDriver.

Referenced by begin().

Here is the caller graph for this function:

◆ from()

static UARTDriver* HALSITL::UARTDriver::from ( AP_HAL::UARTDriver uart)
inlinestatic

Definition at line 24 of file UARTDriver.h.

◆ get_flow_control()

enum flow_control HALSITL::UARTDriver::get_flow_control ( void  )
inlinevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 62 of file UARTDriver.h.

Here is the call graph for this function:

◆ is_initialized()

bool HALSITL::UARTDriver::is_initialized ( )
inlinevirtual

Implements AP_HAL::UARTDriver.

Definition at line 35 of file UARTDriver.h.

◆ read()

int16_t HALSITL::UARTDriver::read ( )
overridevirtual

Implements AP_HAL::BetterStream.

Referenced by _check_reconnect(), and tx_pending().

Here is the caller graph for this function:

◆ receive_time_constraint_us()

uint64_t HALSITL::UARTDriver::receive_time_constraint_us ( uint16_t  nbytes)
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Referenced by _check_reconnect(), and get_flow_control().

Here is the caller graph for this function:

◆ set_blocking_writes()

void HALSITL::UARTDriver::set_blocking_writes ( bool  blocking)
inlinevirtual

Implements AP_HAL::UARTDriver.

Definition at line 39 of file UARTDriver.h.

◆ set_speed()

bool HALSITL::UARTDriver::set_speed ( int  speed)
private

Definition at line 37 of file UART_utils.cpp.

Referenced by _uart_start_connection().

Here is the caller graph for this function:

◆ set_stop_bits()

void HALSITL::UARTDriver::set_stop_bits ( int  n)
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 107 of file UART_utils.cpp.

Referenced by get_flow_control().

Here is the caller graph for this function:

◆ set_unbuffered_writes()

bool HALSITL::UARTDriver::set_unbuffered_writes ( bool  on)
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Referenced by _set_nonblocking(), and get_flow_control().

Here is the caller graph for this function:

◆ tx_pending()

bool HALSITL::UARTDriver::tx_pending ( )
inlinevirtual

Implements AP_HAL::UARTDriver.

Definition at line 44 of file UARTDriver.h.

Here is the call graph for this function:

◆ txspace()

uint32_t HALSITL::UARTDriver::txspace ( )
overridevirtual

Implements AP_HAL::BetterStream.

Referenced by tx_pending().

Here is the caller graph for this function:

◆ write() [1/2]

size_t HALSITL::UARTDriver::write ( uint8_t  c)
virtual

Implements AP_HAL::BetterStream.

Referenced by _check_reconnect(), and tx_pending().

Here is the caller graph for this function:

◆ write() [2/2]

size_t HALSITL::UARTDriver::write ( const uint8_t *  buffer,
size_t  size 
)
virtual

Reimplemented from AP_HAL::BetterStream.

Friends And Related Function Documentation

◆ HALSITL::SITL_State

friend class HALSITL::SITL_State
friend

Definition at line 14 of file UARTDriver.h.

Member Data Documentation

◆ _connected

bool HALSITL::UARTDriver::_connected = false
private

◆ _console

bool HALSITL::UARTDriver::_console
staticprivate

◆ _fd

int HALSITL::UARTDriver::_fd

◆ _listen_fd

int HALSITL::UARTDriver::_listen_fd
private

Definition at line 89 of file UARTDriver.h.

Referenced by _check_connection(), _tcp_start_connection(), and UARTDriver().

◆ _nonblocking_writes

bool HALSITL::UARTDriver::_nonblocking_writes
private

Definition at line 92 of file UARTDriver.h.

Referenced by set_blocking_writes().

◆ _portNumber

uint8_t HALSITL::UARTDriver::_portNumber
private

◆ _readbuffer

ByteBuffer HALSITL::UARTDriver::_readbuffer {16384}
private

Definition at line 93 of file UARTDriver.h.

Referenced by _check_reconnect(), and _uart_start_connection().

◆ _receive_timestamp

uint64_t HALSITL::UARTDriver::_receive_timestamp
private

Definition at line 112 of file UARTDriver.h.

Referenced by _check_reconnect().

◆ _serial_port

int HALSITL::UARTDriver::_serial_port
private

Definition at line 90 of file UARTDriver.h.

◆ _sitlState

SITL_State* HALSITL::UARTDriver::_sitlState
private

Definition at line 111 of file UARTDriver.h.

Referenced by _tcp_start_connection(), _uart_start_connection(), and UARTDriver().

◆ _tcp_client_addr

const char* HALSITL::UARTDriver::_tcp_client_addr
private

Definition at line 100 of file UARTDriver.h.

◆ _uart_baudrate

uint32_t HALSITL::UARTDriver::_uart_baudrate
private

Definition at line 97 of file UARTDriver.h.

Referenced by _check_reconnect(), and _uart_start_connection().

◆ _uart_path

const char* HALSITL::UARTDriver::_uart_path
private

Definition at line 96 of file UARTDriver.h.

Referenced by _check_reconnect(), and _uart_start_connection().

◆ _unbuffered_writes

bool HALSITL::UARTDriver::_unbuffered_writes

Definition at line 60 of file UARTDriver.h.

Referenced by _set_nonblocking().

◆ _use_send_recv

bool HALSITL::UARTDriver::_use_send_recv = false
private

◆ _writebuffer

ByteBuffer HALSITL::UARTDriver::_writebuffer {16384}
private

Definition at line 94 of file UARTDriver.h.

Referenced by _check_reconnect(), and _uart_start_connection().


The documentation for this class was generated from the following files: