APM:Libraries
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PX4::PX4UARTDriver Class Reference

#include <UARTDriver.h>

Inheritance diagram for PX4::PX4UARTDriver:
[legend]
Collaboration diagram for PX4::PX4UARTDriver:
[legend]

Public Member Functions

 PX4UARTDriver (const char *devpath, const char *perf_name)
 
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)
 
void set_device_path (const char *path)
 
void _timer_tick (void) override
 
int _get_fd (void)
 
void set_flow_control (enum flow_control flow_control)
 
enum flow_control get_flow_control (void)
 
void configure_parity (uint8_t v)
 
void set_stop_bits (int n)
 
bool set_unbuffered_writes (bool on)
 
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)
 

Private Member Functions

int _write_fd (const uint8_t *buf, uint16_t n)
 
int _read_fd (uint8_t *buf, uint16_t n)
 
void try_initialise (void)
 

Private Attributes

const char * _devpath
 
int _fd
 
uint32_t _baudrate
 
volatile bool _initialised
 
volatile bool _in_timer
 
bool _nonblocking_writes
 
bool _unbuffered_writes
 
ByteBuffer _readbuf {0}
 
ByteBuffer _writebuf {0}
 
perf_counter_t _perf_uart
 
uint64_t _first_write_time
 
uint64_t _last_write_time
 
uint32_t _last_initialise_attempt_ms
 
uint32_t _os_start_auto_space
 
uint32_t _total_read
 
uint32_t _total_written
 
enum flow_control _flow_control
 
uint64_t _receive_timestamp [2]
 
uint8_t _receive_timestamp_idx
 
Semaphore _semaphore
 
bool _is_usb
 

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 9 of file UARTDriver.h.

Constructor & Destructor Documentation

◆ PX4UARTDriver()

PX4UARTDriver::PX4UARTDriver ( const char *  devpath,
const char *  perf_name 
)

Definition at line 23 of file UARTDriver.cpp.

Member Function Documentation

◆ _get_fd()

int PX4::PX4UARTDriver::_get_fd ( void  )
inline

Definition at line 36 of file UARTDriver.h.

Referenced by PX4::PX4Util::run_debug_shell().

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

◆ _read_fd()

int PX4UARTDriver::_read_fd ( uint8_t *  buf,
uint16_t  n 
)
private

Definition at line 444 of file UARTDriver.cpp.

Referenced by _timer_tick().

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

◆ _timer_tick()

void PX4UARTDriver::_timer_tick ( void  )
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 471 of file UARTDriver.cpp.

Referenced by set_device_path().

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

◆ _write_fd()

int PX4UARTDriver::_write_fd ( const uint8_t *  buf,
uint16_t  n 
)
private

Definition at line 376 of file UARTDriver.cpp.

Referenced by _timer_tick(), and write().

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

◆ available()

uint32_t PX4UARTDriver::available ( void  )
overridevirtual

Implements AP_HAL::BetterStream.

Definition at line 253 of file UARTDriver.cpp.

Referenced by receive_time_constraint_us().

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

◆ begin() [1/2]

void PX4UARTDriver::begin ( uint32_t  b)
virtual

Implements AP_HAL::UARTDriver.

Definition at line 195 of file UARTDriver.cpp.

Referenced by try_initialise().

Here is the caller graph for this function:

◆ begin() [2/2]

void PX4UARTDriver::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.

Definition at line 43 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ configure_parity()

void PX4UARTDriver::configure_parity ( uint8_t  v)
virtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 157 of file UARTDriver.cpp.

Referenced by get_flow_control().

Here is the caller graph for this function:

◆ end()

void PX4UARTDriver::end ( )
virtual

Implements AP_HAL::UARTDriver.

Definition at line 222 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ flush()

void PX4UARTDriver::flush ( void  )
virtual

Implements AP_HAL::UARTDriver.

Definition at line 235 of file UARTDriver.cpp.

◆ get_flow_control()

enum flow_control PX4::PX4UARTDriver::get_flow_control ( void  )
inlinevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 41 of file UARTDriver.h.

Here is the call graph for this function:

◆ is_initialized()

bool PX4UARTDriver::is_initialized ( )
virtual

Implements AP_HAL::UARTDriver.

Definition at line 237 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ read()

int16_t PX4UARTDriver::read ( void  )
overridevirtual

Implements AP_HAL::BetterStream.

Definition at line 279 of file UARTDriver.cpp.

Referenced by _read_fd().

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

◆ receive_time_constraint_us()

uint64_t PX4UARTDriver::receive_time_constraint_us ( uint16_t  nbytes)
overridevirtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 545 of file UARTDriver.cpp.

Referenced by get_flow_control().

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

◆ set_blocking_writes()

void PX4UARTDriver::set_blocking_writes ( bool  blocking)
virtual

Implements AP_HAL::UARTDriver.

Definition at line 243 of file UARTDriver.cpp.

◆ set_device_path()

void PX4::PX4UARTDriver::set_device_path ( const char *  path)
inline

Definition at line 30 of file UARTDriver.h.

Referenced by HAL_PX4::run().

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

◆ set_flow_control()

void PX4UARTDriver::set_flow_control ( enum flow_control flow_control  )

Definition at line 135 of file UARTDriver.cpp.

Referenced by _get_fd(), and _write_fd().

Here is the caller graph for this function:

◆ set_stop_bits()

void PX4UARTDriver::set_stop_bits ( int  n)
virtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 179 of file UARTDriver.cpp.

Referenced by get_flow_control().

Here is the caller graph for this function:

◆ set_unbuffered_writes()

bool PX4UARTDriver::set_unbuffered_writes ( bool  on)
virtual

Reimplemented from AP_HAL::UARTDriver.

Definition at line 190 of file UARTDriver.cpp.

Referenced by get_flow_control().

Here is the caller graph for this function:

◆ try_initialise()

void PX4UARTDriver::try_initialise ( void  )
private

Definition at line 207 of file UARTDriver.cpp.

Referenced by available(), is_initialized(), read(), txspace(), and write().

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

◆ tx_pending()

bool PX4UARTDriver::tx_pending ( )
virtual

Implements AP_HAL::UARTDriver.

Definition at line 248 of file UARTDriver.cpp.

◆ txspace()

uint32_t PX4UARTDriver::txspace ( void  )
overridevirtual

Implements AP_HAL::BetterStream.

Definition at line 266 of file UARTDriver.cpp.

Here is the call graph for this function:

◆ write() [1/2]

size_t PX4UARTDriver::write ( uint8_t  c)
virtual

Implements AP_HAL::BetterStream.

Definition at line 303 of file UARTDriver.cpp.

Referenced by _write_fd(), and write().

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

◆ write() [2/2]

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

Reimplemented from AP_HAL::BetterStream.

Definition at line 338 of file UARTDriver.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _baudrate

uint32_t PX4::PX4UARTDriver::_baudrate
private

Definition at line 65 of file UARTDriver.h.

Referenced by begin(), and receive_time_constraint_us().

◆ _devpath

const char* PX4::PX4UARTDriver::_devpath
private

Definition at line 63 of file UARTDriver.h.

Referenced by _write_fd(), begin(), and set_device_path().

◆ _fd

int PX4::PX4UARTDriver::_fd
private

◆ _first_write_time

uint64_t PX4::PX4UARTDriver::_first_write_time
private

Definition at line 80 of file UARTDriver.h.

Referenced by _write_fd(), and set_flow_control().

◆ _flow_control

enum flow_control PX4::PX4UARTDriver::_flow_control
private

Definition at line 89 of file UARTDriver.h.

Referenced by _write_fd(), get_flow_control(), and set_flow_control().

◆ _in_timer

volatile bool PX4::PX4UARTDriver::_in_timer
private

Definition at line 67 of file UARTDriver.h.

Referenced by _timer_tick(), begin(), and end().

◆ _initialised

volatile bool PX4::PX4UARTDriver::_initialised
private

◆ _is_usb

bool PX4::PX4UARTDriver::_is_usb
private

Definition at line 97 of file UARTDriver.h.

Referenced by _timer_tick(), begin(), and receive_time_constraint_us().

◆ _last_initialise_attempt_ms

uint32_t PX4::PX4UARTDriver::_last_initialise_attempt_ms
private

Definition at line 84 of file UARTDriver.h.

Referenced by try_initialise().

◆ _last_write_time

uint64_t PX4::PX4UARTDriver::_last_write_time
private

Definition at line 81 of file UARTDriver.h.

Referenced by _write_fd().

◆ _nonblocking_writes

bool PX4::PX4UARTDriver::_nonblocking_writes
private

Definition at line 69 of file UARTDriver.h.

Referenced by set_blocking_writes(), and write().

◆ _os_start_auto_space

uint32_t PX4::PX4UARTDriver::_os_start_auto_space
private

Definition at line 86 of file UARTDriver.h.

Referenced by _write_fd().

◆ _perf_uart

perf_counter_t PX4::PX4UARTDriver::_perf_uart
private

Definition at line 76 of file UARTDriver.h.

Referenced by _timer_tick().

◆ _readbuf

ByteBuffer PX4::PX4UARTDriver::_readbuf {0}
private

Definition at line 74 of file UARTDriver.h.

Referenced by _timer_tick(), available(), begin(), end(), and read().

◆ _receive_timestamp

uint64_t PX4::PX4UARTDriver::_receive_timestamp[2]
private

Definition at line 92 of file UARTDriver.h.

Referenced by _timer_tick(), and receive_time_constraint_us().

◆ _receive_timestamp_idx

uint8_t PX4::PX4UARTDriver::_receive_timestamp_idx
private

Definition at line 93 of file UARTDriver.h.

Referenced by _timer_tick(), and receive_time_constraint_us().

◆ _semaphore

Semaphore PX4::PX4UARTDriver::_semaphore
private

Definition at line 95 of file UARTDriver.h.

Referenced by read(), and write().

◆ _total_read

uint32_t PX4::PX4UARTDriver::_total_read
private

Definition at line 87 of file UARTDriver.h.

Referenced by _read_fd().

◆ _total_written

uint32_t PX4::PX4UARTDriver::_total_written
private

Definition at line 88 of file UARTDriver.h.

Referenced by _write_fd(), and set_flow_control().

◆ _unbuffered_writes

bool PX4::PX4UARTDriver::_unbuffered_writes
private

Definition at line 70 of file UARTDriver.h.

Referenced by set_unbuffered_writes(), and write().

◆ _writebuf

ByteBuffer PX4::PX4UARTDriver::_writebuf {0}
private

Definition at line 75 of file UARTDriver.h.

Referenced by _timer_tick(), begin(), end(), txspace(), and write().


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