mia_hand_driver  rel 1.0.0
mia_hand::SerialPort Class Reference

Class to handle a serial port and its serial communication protocol. More...

#include <serial_port.h>

Inheritance diagram for mia_hand::SerialPort:
Collaboration diagram for mia_hand::SerialPort:

Public Member Functions

 SerialPort (std::mutex *p_finger_data_mtx, std::mutex *p_connection_mtx, bool *p_is_connected)
 Class destructor. More...
 
 ~SerialPort ()
 Class destructor. More...
 
bool open (uint16_t port_num)
 Open a serial port. More...
 
bool close ()
 Close the serial port. More...
 
void sendCommand (const std::string &command)
 Send a command to the Mia hand attached to the serial port. More...
 
void parseStream (FingerSerialInfo &thumb, FingerSerialInfo &index, FingerSerialInfo &mrl, bool &is_checking_on)
 Parse message received from the Mia hand. More...
 

Private Attributes

std::string stream_msg_
 Message received from the Mia hand. More...
 
std::mutex serial_write_mtx_
 
std::mutex * p_finger_data_mtx_
 
std::mutex * p_connection_mtx_
 
bool * p_is_connected_
 

Detailed Description

Class to handle a serial port and its serial communication protocol.

Definition at line 42 of file serial_port.h.

Constructor & Destructor Documentation

◆ SerialPort()

mia_hand::SerialPort::SerialPort ( std::mutex *  p_finger_data_mtx,
std::mutex *  p_connection_mtx,
bool *  p_is_connected 
)

Class destructor.

Definition at line 14 of file serial_port.cpp.

◆ ~SerialPort()

mia_hand::SerialPort::~SerialPort ( )

Class destructor.

Definition at line 23 of file serial_port.cpp.

Member Function Documentation

◆ close()

bool mia_hand::SerialPort::close ( )

Close the serial port.

Definition at line 65 of file serial_port.cpp.

◆ open()

bool mia_hand::SerialPort::open ( uint16_t  port_num)

Open a serial port.

Parameters
port_numinteger number of the serial port to open.

Definition at line 31 of file serial_port.cpp.

◆ parseStream()

void mia_hand::SerialPort::parseStream ( FingerSerialInfo thumb,
FingerSerialInfo index,
FingerSerialInfo mrl,
bool &  is_checking_on 
)

Parse message received from the Mia hand.

Parameters
thumbReceived info regarding the thumb flexion motor.
indexReceived info regarding the index flexion motor.
mrlReceived info regarding the mrl flexion motor.
is_checking_onboolean to handle the check of the Mia hand connection.

Definition at line 109 of file serial_port.cpp.

◆ sendCommand()

void mia_hand::SerialPort::sendCommand ( const std::string &  command)

Send a command to the Mia hand attached to the serial port.

This commands add to the input message the proper tail and send the composed message to the Mia hand.

Parameters
commandcommand to be sent.

Definition at line 85 of file serial_port.cpp.

Member Data Documentation

◆ p_connection_mtx_

std::mutex* mia_hand::SerialPort::p_connection_mtx_
private

Definition at line 91 of file serial_port.h.

◆ p_finger_data_mtx_

std::mutex* mia_hand::SerialPort::p_finger_data_mtx_
private

Definition at line 90 of file serial_port.h.

◆ p_is_connected_

bool* mia_hand::SerialPort::p_is_connected_
private

Definition at line 93 of file serial_port.h.

◆ serial_write_mtx_

std::mutex mia_hand::SerialPort::serial_write_mtx_
private

Definition at line 89 of file serial_port.h.

◆ stream_msg_

std::string mia_hand::SerialPort::stream_msg_
private

Message received from the Mia hand.

Definition at line 87 of file serial_port.h.


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