blmc_drivers
blmc_drivers::SerialReader Class Reference

Public Member Functions

 SerialReader (const std::string &serial_port, const int &num_values)
 
int fill_vector (std::vector< int > &values)
 Fills a vector with the latest values. More...
 

Private Member Functions

void loop ()
 This is the real time thread that streams the data to/from the main board.
 

Static Private Member Functions

static THREAD_FUNCTION_RETURN_TYPE loop (void *instance_pointer)
 This is the helper function used for spawning the real time thread. More...
 

Private Attributes

bool is_loop_active_
 This boolean makes sure that the loop is stopped upon destruction of this object.
 
real_time_tools::RealTimeThread rt_thread_
 This is the thread object that allow to spwan a real-time thread or not dependening on the current OS.
 
int fd_
 Holds the device serial port.
 
bool has_error_
 If false, the communication is workinng as expected.
 
bool is_active_
 If the communication is active.
 
int new_data_counter_
 
int missed_data_counter_
 
std::vector< int > latest_values_
 Holds vector with the latest double values.
 
std::mutex mutex_
 mutex_ multithreading safety
 

Constructor & Destructor Documentation

◆ SerialReader()

blmc_drivers::SerialReader::SerialReader ( const std::string &  serial_port,
const int &  num_values 
)
Parameters
serial_portThe address of the serial port to use. num_values The number of values to read in each line.

Member Function Documentation

◆ fill_vector()

int blmc_drivers::SerialReader::fill_vector ( std::vector< int > &  values)

Fills a vector with the latest values.

Parameters
valuesVector to place values into.
Returns
How often fill_vector was called without new data.

◆ loop()

static THREAD_FUNCTION_RETURN_TYPE blmc_drivers::SerialReader::loop ( void *  instance_pointer)
inlinestaticprivate

This is the helper function used for spawning the real time thread.

Parameters
instance_pointeris the current object in this case.
Returns
THREAD_FUNCTION_RETURN_TYPE depends on the current OS.

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