SVHSerialInterface.h
Go to the documentation of this file.
1 //
3 // © Copyright 2022 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
4 // © Copyright 2022 FZI Forschungszentrum Informatik, Karlsruhe, Germany
5 //
6 // This file is part of the Schunk SVH Library.
7 //
8 // The Schunk SVH Library is free software: you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or (at your
11 // option) any later version.
12 //
13 // The Schunk SVH Library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 // Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // the Schunk SVH Library. If not, see <https://www.gnu.org/licenses/>.
20 //
22 
23 //----------------------------------------------------------------------
37 //----------------------------------------------------------------------
38 #ifndef DRIVER_SVH_SVH_SERIAL_INTERFACE_H_INCLUDED
39 #define DRIVER_SVH_SVH_SERIAL_INTERFACE_H_INCLUDED
40 
41 // Windows declarations
43 
44 #include <memory>
48 #include <thread>
49 
51 
52 namespace driver_svh {
53 
58 {
59 public:
64  SVHSerialInterface(const ReceivedPacketCallback& received_packet_callback);
65 
68 
74  bool connect(const std::string& dev_name);
75 
79  void close();
80 
85  bool isConnected() { return m_connected; }
86 
92  bool sendPacket(SVHSerialPacket& packet);
93 
98  unsigned int transmittedPacketCount() { return m_packets_transmitted; }
99 
103  void resetTransmitPackageCount();
104 
110  void printPacketOnConsole(SVHSerialPacket& packet);
111 
112 private:
113  void receivedPacketCallback(const SVHSerialPacket& packet, unsigned int packet_count);
114 
117 
118  uint8_t m_last_index;
119 
121  std::shared_ptr<Serial> m_serial_device;
122 
124  void calcCheckSum(uint8_t& check_sum1, uint8_t& check_sum2, const SVHSerialPacket& packet);
125 
127  std::thread m_receive_thread;
128 
130  std::unique_ptr<SVHReceiveThread> m_svh_receiver;
131 
134 
136  unsigned int m_packets_transmitted;
137 
140 };
141 
142 } // namespace driver_svh
143 
144 #endif
driver_svh::SVHSerialPacket
The SerialPacket holds the (non generated) header and data of one message to the SVH-Hardware.
Definition: SVHSerialPacket.h:80
receivedPacketCallback
void receivedPacketCallback(const SVHSerialPacket &packet, unsigned int packet_count)
Definition: SVHReceiveFeedbackPacketTest.cpp:45
driver_svh::SVHSerialInterface::m_svh_receiver
std::unique_ptr< SVHReceiveThread > m_svh_receiver
handle to manage the actual receiving of data
Definition: SVHSerialInterface.h:130
driver_svh::SVHSerialInterface::m_received_packet_callback
ReceivedPacketCallback m_received_packet_callback
Callback function for received packets.
Definition: SVHSerialInterface.h:133
driver_svh
Definition: SVHControlCommand.h:39
SVHReceiveThread.h
driver_svh::SVHSerialInterface::m_serial_device
std::shared_ptr< Serial > m_serial_device
pointer to serial interface object
Definition: SVHSerialInterface.h:121
driver_svh::SVHSerialInterface::isConnected
bool isConnected()
returns connected state of serial device
Definition: SVHSerialInterface.h:85
driver_svh::SVHSerialInterface::m_receive_thread
std::thread m_receive_thread
thread for receiving serial packets
Definition: SVHSerialInterface.h:127
driver_svh::SVHSerialInterface::transmittedPacketCount
unsigned int transmittedPacketCount()
get number of transmitted packets
Definition: SVHSerialInterface.h:98
DRIVER_SVH_IMPORT_EXPORT
#define DRIVER_SVH_IMPORT_EXPORT
Definition: ImportExport.h:50
driver_svh::SVHSerialInterface::m_last_index
uint8_t m_last_index
Definition: SVHSerialInterface.h:118
SVHSerialPacket.h
driver_svh::ReceivedPacketCallback
std::function< void(const SVHSerialPacket &packet, unsigned int packet_count)> ReceivedPacketCallback
definition of function callback for received packages
Definition: SVHReceiveThread.h:59
Serial.h
Contains a class that enables access to serial devices.
driver_svh::SVHSerialInterface::m_connected
bool m_connected
serial device connected state
Definition: SVHSerialInterface.h:116
driver_svh::serial::Serial
Enables acces to serial devices.
Definition: Serial.h:68
ImportExport.h
driver_svh::SVHSerialInterface::m_dummy_packets_printed
unsigned int m_dummy_packets_printed
packet counter simulation for pure showing purposes
Definition: SVHSerialInterface.h:139
driver_svh::SVHSerialInterface::m_packets_transmitted
unsigned int m_packets_transmitted
packet counters
Definition: SVHSerialInterface.h:136
driver_svh::SVHSerialInterface
Basic communication handler for the SCHUNK five finger hand.
Definition: SVHSerialInterface.h:57


schunk_svh_library
Author(s): Georg Heppner, Lars Pfotzer, Felix Exner, Johannes Mangler, Stefan Scherzinger, Pascal Becker
autogenerated on Fri Apr 14 2023 02:53:52