SVHReceiveThread.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of the SCHUNK SVH Driver suite.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
12 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
13 //
14 // -- END LICENSE BLOCK ------------------------------------------------
15 
16 //----------------------------------------------------------------------
29 //----------------------------------------------------------------------
30 #ifndef DRIVER_SVH_SVH_RECEIVE_THREAD_H_INCLUDED
31 #define DRIVER_SVH_SVH_RECEIVE_THREAD_H_INCLUDED
32 
33 #include <icl_core/TimeSpan.h>
35 #include <icl_comm_serial/Serial.h>
36 #include <icl_comm/ByteOrderConversion.h>
37 
38 #include <driver_svh/Logging.h>
40 
41 #include <boost/function.hpp>
42 #include <boost/shared_ptr.hpp>
43 
44 using icl_core::TimeSpan;
46 using icl_comm::serial::Serial;
47 
48 namespace driver_svh {
49 
51 typedef boost::function<void (const SVHSerialPacket& packet, unsigned int packet_count)> ReceivedPacketCallback;
52 
57 {
58 public:
67  ReceivedPacketCallback const & received_callback);
68 
70  virtual ~SVHReceiveThread() {}
71 
73  virtual void run();
74 
76  unsigned int receivedPacketCount() { return m_packets_received; }
77 
82 
83 private:
84 
87 
89  enum
90  {
100  } typedef tState;
101 
104 
110 
112  std::vector<uint8_t> m_data;
113 
115  icl_comm::ArrayBuilder m_ab;
116 
118  unsigned int m_packets_received;
120  unsigned int m_skipped_bytes;
121 
123  bool receiveData();
124 
126  ReceivedPacketCallback m_received_callback;
127 
128 };
129 
130 }
131 
132 #endif
std::vector< uint8_t > m_data
length of received serial data
tState m_received_state
current state of the state machine
boost::function< void(const SVHSerialPacket &packet, unsigned int packet_count)> ReceivedPacketCallback
definition of boost function callback for received packages
unsigned int m_skipped_bytes
counter for skipped bytes in case no packet is detected
ReceivedPacketCallback m_received_callback
function callback for received packages
bool receiveData()
state machine processing received data
void resetReceivedPackageCount()
resetReceivedPackageCount Resets the received package count to zero. This can be usefull to set all c...
tState
enum for receive packet state machine states
virtual void run()
run method of the thread, executes the main program
unsigned int receivedPacketCount()
return the count of received packets
uint16_t m_length
length of received serial data
Thread for receiving messages from the serial device.
unsigned char uint8_t
virtual ~SVHReceiveThread()
Default DTOR.
unsigned int m_packets_received
packets counter
SVHReceiveThread(const TimeSpan &period, boost::shared_ptr< Serial > device, ReceivedPacketCallback const &received_callback)
SVHReceiveThread Constructs a new Receivethread.
boost::shared_ptr< Serial > m_serial_device
pointer to serial device object
icl_core::TimeSpan period() const
uint8_t m_checksum1
Checksum of packet.
unsigned short uint16_t
icl_comm::ArrayBuilder m_ab
pointer to array builder object for packet receive


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Mon Jun 10 2019 15:04:59