Go to the documentation of this file.
53 , m_received_packet_callback(received_packet_callback)
54 , m_packets_transmitted(0)
70 new Serial(dev_name.c_str(),
SerialFlags(SerialFlags::BR_921600, SerialFlags::DB_8)));
78 "Could not open serial device: " << dev_name.c_str());
85 "Could not create serial device handle: " << dev_name.c_str());
90 std::make_unique<SVHReceiveThread>(std::chrono::microseconds(500),
94 std::placeholders::_1,
95 std::placeholders::_2));
104 <<
" opened and receive thread started. Communication can now begin.");
139 packet.
data.resize(64, 0);
141 uint8_t check_sum1 = 0;
142 uint8_t check_sum2 = 0;
145 for (
size_t i = 0; i < packet.
data.size(); i++)
147 check_sum1 += packet.
data[i];
148 check_sum2 ^= packet.
data[i];
163 ssize_t bytes_send = 0;
164 while (bytes_send < size)
174 std::this_thread::sleep_for(std::chrono::microseconds(782));
181 "sendPacket failed, serial device was not properly initialized.");
200 uint8_t check_sum1 = 0;
201 uint8_t check_sum2 = 0;
204 for (
size_t i = 0; i < packet.
data.size(); i++)
206 check_sum1 += packet.
data[i];
207 check_sum2 ^= packet.
data[i];
220 std::cout << send_array << std::endl;
226 unsigned int packet_count)
std::vector< uint8_t > array
array of template type TArray
The SerialPacket holds the (non generated) header and data of one message to the SVH-Hardware.
void resetTransmitPackageCount()
resetTransmitPackageCount Resets the transmitpackage count to zero
std::vector< uint8_t > data
Payload of the package.
std::unique_ptr< SVHReceiveThread > m_svh_receiver
handle to manage the actual receiving of data
#define SVH_LOG_ERROR_STREAM(NAME, M)
void close()
canceling receive thread and closing connection to serial port
ReceivedPacketCallback m_received_packet_callback
Callback function for received packets.
uint8_t index
Continuosly incremented counter per package.
const uint8_t PACKET_HEADER2
Header sync byte 2.
~SVHSerialInterface()
Default DTOR.
SVHSerialInterface(const ReceivedPacketCallback &received_packet_callback)
Constructs a serial interface class for basic communication with the SCHUNK five finger hand.
void receivedPacketCallback(const SVHSerialPacket &packet, unsigned int packet_count)
std::shared_ptr< Serial > m_serial_device
pointer to serial interface object
const size_t C_PACKET_APPENDIX_SIZE
The packet overhead size in bytes.
std::thread m_receive_thread
thread for receiving serial packets
bool sendPacket(SVHSerialPacket &packet)
function for sending packets via serial device to the SVH
std::function< void(const SVHSerialPacket &packet, unsigned int packet_count)> ReceivedPacketCallback
definition of function callback for received packages
void printPacketOnConsole(SVHSerialPacket &packet)
printPacketOnConsole is a pure helper function to show what raw data is actually sent....
bool m_connected
serial device connected state
const uint8_t PACKET_HEADER1
Header sync byte 1.
Enables acces to serial devices.
Short description of tSerialFlags.
unsigned int m_dummy_packets_printed
packet counter simulation for pure showing purposes
unsigned int m_packets_transmitted
packet counters
bool connect(const std::string &dev_name)
connecting to serial device and starting receive thread
#define SVH_LOG_DEBUG_STREAM(NAME, M)
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