Interface for TCP/IP. More...
#include <sick_scan_common_nw.h>
Public Member Functions | |
bool | connect () |
Connects to a sensor via tcp and reads the device name. More... | |
bool | disconnect () |
Closes the connection to the LMS. This is the opposite of init(). More... | |
uint64_t | getNanosecTimestampLastTcpMessageReceived (void) |
bool | init (std::string ipAddress, unsigned short portNumber, Tcp::DisconnectFunction disconnectFunction, void *obj) |
bool | isConnected () |
Returns true if the tcp connection is established. More... | |
bool | sendCommandBuffer (UINT8 *buffer, UINT16 len) |
bool | setReadCallbackFunction (Tcp::ReadFunction readFunction, void *obj) |
SickScanCommonNw () | |
~SickScanCommonNw () | |
Protected Types | |
enum | State { CONSTRUCTED, CONNECTED } |
Protected Attributes | |
State | m_state |
Private Member Functions | |
void | closeTcpConnection () |
void | copyFrameToResposeBuffer (UINT32 frameLength) |
SopasEventMessage | findFrameInReceiveBuffer () |
bool | openTcpConnection () |
void | processFrame (SopasEventMessage &frame) |
void | readCallbackFunction (UINT8 *buffer, UINT32 &numOfBytes) |
void | removeFrameFromReceiveBuffer (UINT32 frameLength) |
Static Private Member Functions | |
static void | readCallbackFunctionS (void *obj, UINT8 *buffer, UINT32 &numOfBytes) |
Function that will be called on incomming data via tcp. More... | |
Private Attributes | |
bool | m_beVerbose |
std::string | m_ipAddress |
UINT32 | m_numberOfBytesInReceiveBuffer |
Number of bytes in buffer. More... | |
UINT32 | m_numberOfBytesInResponseBuffer |
Number of bytes in buffer. More... | |
UINT16 | m_portNumber |
SopasProtocol | m_protocol |
UINT8 | m_receiveBuffer [25000] |
Low-Level receive buffer for all data (25000 should be enough for NAV300 Events) More... | |
Mutex | m_receiveDataMutex |
Access mutex for buffer. More... | |
UINT8 | m_responseBuffer [1024] |
Receive buffer for everything except scan data and eval case data. More... | |
Tcp | m_tcp |
Interface for TCP/IP.
This class provides an interface for TCP/IP communication. It also contains simple methods for accessing the essential contents of the SOPAS message (for example, determining the payload and the SOPAS command used). It based on an example of SICK AG.
Doxygen example: http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/doxygen-howto.html
Definition at line 39 of file sick_scan_common_nw.h.
|
protected |
Enumerator | |
---|---|
CONSTRUCTED | Object has been constructed. Use init() to go into CONNECTED state. Object is now connected. Use run() to go into RUNNING state, or disconnect() to go back into CONSTRUCTED state. |
CONNECTED | Object is connected and emitting data. Use stop() to go back into CONNECTED, or disconnect() to go back into CONSTRUCTED state. |
Definition at line 117 of file sick_scan_common_nw.h.
SickScanCommonNw::SickScanCommonNw | ( | ) |
Definition at line 81 of file sick_scan_common_nw.cpp.
SickScanCommonNw::~SickScanCommonNw | ( | ) |
Definition at line 88 of file sick_scan_common_nw.cpp.
|
private |
Definition at line 207 of file sick_scan_common_nw.cpp.
bool SickScanCommonNw::connect | ( | ) |
Connects to a sensor via tcp and reads the device name.
Definition at line 142 of file sick_scan_common_nw.cpp.
|
private |
Definition at line 515 of file sick_scan_common_nw.cpp.
bool SickScanCommonNw::disconnect | ( | ) |
Closes the connection to the LMS. This is the opposite of init().
Switches this device from the CONNECTED state back in the CONSTRUCTED state.
Definition at line 102 of file sick_scan_common_nw.cpp.
|
private |
Definition at line 302 of file sick_scan_common_nw.cpp.
uint64_t SickScanCommonNw::getNanosecTimestampLastTcpMessageReceived | ( | void | ) |
Returns a timestamp in nanoseconds of the last received tcp message (or 0 if no message received)
Definition at line 199 of file sick_scan_common_nw.cpp.
bool SickScanCommonNw::init | ( | std::string | ipAddress, |
unsigned short | portNumber, | ||
Tcp::DisconnectFunction | disconnectFunction, | ||
void * | obj | ||
) |
Definition at line 116 of file sick_scan_common_nw.cpp.
bool SickScanCommonNw::isConnected | ( | ) |
Returns true if the tcp connection is established.
Definition at line 171 of file sick_scan_common_nw.cpp.
|
private |
Open TCP-connection to endpoint (usually IP-address and port)
true = Connected, false = no connection
Definition at line 182 of file sick_scan_common_nw.cpp.
|
private |
Reads one frame from receive buffer and decodes it. Switches directly to the decoder of the protocol.
Definition at line 490 of file sick_scan_common_nw.cpp.
Read callback. Diese Funktion wird aufgerufen, sobald Daten auf der Schnittstelle hereingekommen sind.
Definition at line 228 of file sick_scan_common_nw.cpp.
|
staticprivate |
Function that will be called on incomming data via tcp.
Definition at line 218 of file sick_scan_common_nw.cpp.
|
private |
Definition at line 540 of file sick_scan_common_nw.cpp.
Send contents of buffer to scanner using according framing.
Send buffer is limited to 1024 byte!
Definition at line 479 of file sick_scan_common_nw.cpp.
bool SickScanCommonNw::setReadCallbackFunction | ( | Tcp::ReadFunction | readFunction, |
void * | obj | ||
) |
Definition at line 128 of file sick_scan_common_nw.cpp.
|
private |
Definition at line 91 of file sick_scan_common_nw.h.
|
private |
Definition at line 107 of file sick_scan_common_nw.h.
|
private |
Number of bytes in buffer.
Definition at line 100 of file sick_scan_common_nw.h.
|
private |
Number of bytes in buffer.
Definition at line 95 of file sick_scan_common_nw.h.
|
private |
Definition at line 108 of file sick_scan_common_nw.h.
|
private |
Definition at line 109 of file sick_scan_common_nw.h.
|
private |
Low-Level receive buffer for all data (25000 should be enough for NAV300 Events)
Definition at line 101 of file sick_scan_common_nw.h.
|
private |
Access mutex for buffer.
Definition at line 97 of file sick_scan_common_nw.h.
|
private |
Receive buffer for everything except scan data and eval case data.
Definition at line 96 of file sick_scan_common_nw.h.
|
protected |
Definition at line 130 of file sick_scan_common_nw.h.
|
private |
Definition at line 106 of file sick_scan_common_nw.h.