mia_hand_driver  rel 1.0.0
serial_port.h
Go to the documentation of this file.
1 /*********************************************************************************************************
2 Modifyed by Author: Prensilia srl
3 Desc: Serial com port cpp hanlder.
4 
5 version 1.0
6 
7 **********************************************************************************************************/
8 
9 
10 #ifndef MIA_HAND_SERIAL_PORT_H
11 #define MIA_HAND_SERIAL_PORT_H
12 
13 #include "libserial/SerialPort.h"
14 #include <mutex>
15 
16 namespace mia_hand
17 {
18 
22 typedef struct FingerSerialInfo
23 {
24 
26 
27  int16_t mot_pos;
28  int8_t mot_spe;
29  int16_t mot_cur;
30  int16_t fin_sg_raw[2];
32 
36 class SerialPort: public LibSerial::SerialPort
37 {
38 public:
39 
43  SerialPort(std::mutex* p_finger_data_mtx, std::mutex* p_connection_mtx,
44  bool* p_is_connected);
45 
49  ~SerialPort();
50 
55  bool open(uint16_t port_num);
56 
60  bool close();
61 
67  void sendCommand(const std::string& command);
68 
76  void parseStream(FingerSerialInfo& thumb, FingerSerialInfo& index,
77  FingerSerialInfo& mrl, bool& is_checking_on);
78 
79 private:
80 
81  std::string stream_msg_;
82 
83  std::mutex serial_write_mtx_;
84  std::mutex* p_finger_data_mtx_;
85  std::mutex* p_connection_mtx_;
86 
88 };
89 } // namespace
90 
91 #endif // MIA_HAND_SERIAL_PORT_H
mia_hand::SerialPort::SerialPort
SerialPort(std::mutex *p_finger_data_mtx, std::mutex *p_connection_mtx, bool *p_is_connected)
Class destructor.
Definition: serial_port.cpp:14
mia_hand::FingerSerialInfo::fin_sg_raw
int16_t fin_sg_raw[2]
Definition: serial_port.h:42
mia_hand::SerialPort::close
bool close()
Close the serial port.
Definition: serial_port.cpp:65
mia_hand::FingerSerialInfo
Struct containing all info that could regard a Mia hand motor.
Definition: serial_port.h:28
mia_hand::FingerSerialInfo::FingerSerialInfo
FingerSerialInfo()
Definition: serial_port.cpp:5
mia_hand::SerialPort::sendCommand
void sendCommand(const std::string &command)
Send a command to the Mia hand attached to the serial port.
Definition: serial_port.cpp:85
mia_hand::SerialPort::p_is_connected_
bool * p_is_connected_
Definition: serial_port.h:93
mia_hand::SerialPort::~SerialPort
~SerialPort()
Class destructor.
Definition: serial_port.cpp:23
mia_hand::SerialPort::open
bool open(uint16_t port_num)
Open a serial port.
Definition: serial_port.cpp:31
mia_hand::FingerSerialInfo::mot_cur
int16_t mot_cur
Definition: serial_port.h:41
mia_hand::SerialPort::p_connection_mtx_
std::mutex * p_connection_mtx_
Definition: serial_port.h:91
mia_hand::SerialPort
Class to handle a serial port and its serial communication protocol.
Definition: serial_port.h:42
mia_hand::FingerSerialInfo::mot_pos
int16_t mot_pos
Definition: serial_port.h:39
mia_hand::FingerSerialInfo::mot_spe
int8_t mot_spe
Definition: serial_port.h:40
mia_hand::SerialPort::parseStream
void parseStream(FingerSerialInfo &thumb, FingerSerialInfo &index, FingerSerialInfo &mrl, bool &is_checking_on)
Parse message received from the Mia hand.
Definition: serial_port.cpp:109
mia_hand::SerialPort::serial_write_mtx_
std::mutex serial_write_mtx_
Definition: serial_port.h:89
mia_hand
Definition: cpp_driver.h:16
mia_hand::FingerSerialInfo
struct mia_hand::FingerSerialInfo FingerSerialInfo
Struct containing all info that could regard a Mia hand motor.
mia_hand::SerialPort::stream_msg_
std::string stream_msg_
Message received from the Mia hand.
Definition: serial_port.h:87
mia_hand::SerialPort::p_finger_data_mtx_
std::mutex * p_finger_data_mtx_
Definition: serial_port.h:90