Thread for receiving messages from the serial device. More...
#include <SVHReceiveThread.h>
Public Member Functions | |
unsigned int | receivedPacketCount () |
return the count of received packets More... | |
void | resetReceivedPackageCount () |
resetReceivedPackageCount Resets the received package count to zero. This can be usefull to set all communication variables to the initial state More... | |
virtual void | run () |
run method of the thread, executes the main program More... | |
SVHReceiveThread (const TimeSpan &period, boost::shared_ptr< Serial > device, ReceivedPacketCallback const &received_callback) | |
SVHReceiveThread Constructs a new Receivethread. More... | |
virtual | ~SVHReceiveThread () |
Default DTOR. More... | |
Public Member Functions inherited from icl_core::thread::PeriodicThread | |
icl_core::TimeSpan | period () const |
PeriodicThread (const icl_core::String &description, const icl_core::TimeSpan &period, ThreadPriority priority=0) | |
bool | setPeriod (const icl_core::TimeSpan &period) |
virtual | ~PeriodicThread () |
Public Member Functions inherited from icl_core::thread::Thread | |
void | cancel () |
bool | checkHardRealtime () |
bool | execute () const |
bool | executesHardRealtime () const |
icl_core::String | getDescription () const |
bool | isHardRealtime () const |
void | join () |
virtual void | onStop () |
icl_core::ThreadPriority | priority () const |
bool | running () const |
void | setDescription (const icl_core::String &description) |
bool | setHardRealtime (bool hard_realtime=true) |
bool | setPriority (icl_core::ThreadPriority priority) |
bool | start () |
void | stop () |
Thread (const icl_core::String &description, icl_core::ThreadPriority priority=0) | |
icl_core::ThreadId | threadId () const |
const char * | threadInfo () const |
bool | threadSelf () const |
bool | wait (const icl_core::TimeSpan &timeout) |
bool | wait () |
bool | wait (const icl_core::TimeStamp &timeout) |
virtual | ~Thread () |
Private Types | |
enum | tState { eRS_HEADER1, eRS_HEADER2, eRS_INDEX, eRS_ADDRESS, eRS_LENGTH1, eRS_LENGTH2, eRS_DATA, eRS_CHECKSUM1, eRS_CHECKSUM2 } |
enum for receive packet state machine states More... | |
Private Member Functions | |
bool | receiveData () |
state machine processing received data More... | |
Private Attributes | |
icl_comm::ArrayBuilder | m_ab |
pointer to array builder object for packet receive More... | |
uint8_t | m_checksum1 |
Checksum of packet. More... | |
uint8_t | m_checksum2 |
std::vector< uint8_t > | m_data |
length of received serial data More... | |
uint16_t | m_length |
length of received serial data More... | |
unsigned int | m_packets_received |
packets counter More... | |
ReceivedPacketCallback | m_received_callback |
function callback for received packages More... | |
tState | m_received_state |
current state of the state machine More... | |
boost::shared_ptr< Serial > | m_serial_device |
pointer to serial device object More... | |
unsigned int | m_skipped_bytes |
counter for skipped bytes in case no packet is detected More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from icl_core::thread::Thread | |
static icl_core::ThreadId | selfId () |
Protected Member Functions inherited from icl_core::thread::PeriodicThread | |
void | waitPeriod () |
Protected Member Functions inherited from icl_core::Noncopyable | |
Noncopyable () | |
virtual | ~Noncopyable () |
Thread for receiving messages from the serial device.
Definition at line 56 of file SVHReceiveThread.h.
|
private |
enum for receive packet state machine states
Enumerator | |
---|---|
eRS_HEADER1 | |
eRS_HEADER2 | |
eRS_INDEX | |
eRS_ADDRESS | |
eRS_LENGTH1 | |
eRS_LENGTH2 | |
eRS_DATA | |
eRS_CHECKSUM1 | |
eRS_CHECKSUM2 |
Definition at line 89 of file SVHReceiveThread.h.
driver_svh::SVHReceiveThread::SVHReceiveThread | ( | const TimeSpan & | period, |
boost::shared_ptr< Serial > | device, | ||
ReceivedPacketCallback const & | received_callback | ||
) |
SVHReceiveThread Constructs a new Receivethread.
period | The relative period after which the thread is cyclically woken up. |
device | handle of the serial device |
received_callback | function to call uppon finished packet |
Definition at line 38 of file SVHReceiveThread.cpp.
|
inlinevirtual |
Default DTOR.
Definition at line 70 of file SVHReceiveThread.h.
|
private |
state machine processing received data
Definition at line 80 of file SVHReceiveThread.cpp.
|
inline |
return the count of received packets
Definition at line 76 of file SVHReceiveThread.h.
|
inline |
resetReceivedPackageCount Resets the received package count to zero. This can be usefull to set all communication variables to the initial state
Definition at line 81 of file SVHReceiveThread.h.
|
virtual |
run method of the thread, executes the main program
Implements icl_core::thread::Thread.
Definition at line 51 of file SVHReceiveThread.cpp.
|
private |
pointer to array builder object for packet receive
Definition at line 115 of file SVHReceiveThread.h.
|
private |
Checksum of packet.
Definition at line 108 of file SVHReceiveThread.h.
|
private |
Definition at line 109 of file SVHReceiveThread.h.
|
private |
length of received serial data
Definition at line 112 of file SVHReceiveThread.h.
|
private |
length of received serial data
Definition at line 106 of file SVHReceiveThread.h.
|
private |
packets counter
Definition at line 118 of file SVHReceiveThread.h.
|
private |
function callback for received packages
Definition at line 126 of file SVHReceiveThread.h.
|
private |
current state of the state machine
Definition at line 103 of file SVHReceiveThread.h.
|
private |
pointer to serial device object
Definition at line 86 of file SVHReceiveThread.h.
|
private |
counter for skipped bytes in case no packet is detected
Definition at line 120 of file SVHReceiveThread.h.