sick_scan_common_nw.h
Go to the documentation of this file.
1 //
2 // Created by michael on 1/22/18.
3 //
4 
5 #ifndef SICK_SCAN_SICK_SCAN_COMMON_NW_H
6 #define SICK_SCAN_SICK_SCAN_COMMON_NW_H
7 
9 #include "sick_scan/tcp/tcp.hpp"
10 #include <map> // for std::map
11 
12 //
13 // SickScanCommonNw.cpp
14 //
15 // Created on: 18.07.2011
16 // Author: sick
17 //
18 #include "sick_scan/tcp/tcp.hpp"
21 #include "sick_scan/tcp/Mutex.hpp"
22 
23 
24 #include <string>
25 class SopasEventMessage;
26 class SopasAnswer;
27 
29  {
33  };
34 
35 
37  {
38 public:
39 
40 
41 
44  bool init(std::string ipAddress,
45  unsigned short portNumber,
46  Tcp::DisconnectFunction disconnectFunction,
47  void* obj);
49  void* obj);
50 
52  bool connect();
53 
55  bool isConnected();
56 
64  bool disconnect();
65  void sendCommandBuffer(UINT8* buffer, UINT16 len);
66 
67 private:
68  // TCP
69  bool openTcpConnection();
70  void closeTcpConnection();
71 
73  static void readCallbackFunctionS(void* obj, UINT8* buffer, UINT32& numOfBytes);
74  void readCallbackFunction(UINT8* buffer, UINT32& numOfBytes);
75 
77  void processFrame(SopasEventMessage& frame);
78 
80 
81 
82 
83 
84 
85  // Response buffer
89 
90  // Receive buffer
93 
94 
95 
96  // TCP
98  std::string m_ipAddress;
101 
102 
103  void copyFrameToResposeBuffer(UINT32 frameLength);
104  void removeFrameFromReceiveBuffer(UINT32 frameLength);
105 protected:
106  enum State
107  {
112  ,
116  // , RUNNING
117  };
118 
120  };
121 
124  {
125 public:
128 
131 
139  SopasEventMessage(BYTE* buffer, SopasProtocol protocol, UINT32 frameLength);
140 
142  {
143  return m_protocol;
144  }
145 
146 
147  UINT32 size() const
148  {
149  return m_frameLength;
150  }
151 
153  UINT32 getPayLoadLength() const;
154 
155  std::string getCommandString() const;
156 
158  BYTE* getPayLoad();
159 
160  BYTE* getRawData();
162  INT32 getVariableIndex();
163 
165  std::string getVariableName();
166 
167  bool isValid() const { return (m_buffer != NULL); }
168 
169 private:
170  void detectEncoding();
171 
172  void detectMessageType();
173 
174 private:
178  };
179 
182  {
183 public:
185  SopasAnswer(const BYTE* answer, UINT32 answerLength);
186 
188  ~SopasAnswer();
189 
190  BYTE* getBuffer() { return m_answerBuffer; }
191 
192  UINT32 size() { return m_answerLength; }
193 
194  bool isValid() { return (m_answerBuffer != NULL); }
195 
196 private:
199  };
200 
201 #endif //SICK_SCAN_SICK_SCAN_COMMON_NW_H
unsigned char BYTE
SopasEventMessage findFrameInReceiveBuffer()
uint16_t UINT16
Class that encapsulates a buffer that was sent as return to a sync call. (variable / method) ...
bool init(std::string ipAddress, unsigned short portNumber, Tcp::DisconnectFunction disconnectFunction, void *obj)
void processFrame(SopasEventMessage &frame)
UINT8 m_responseBuffer[1024]
Receive buffer for everything except scan data and eval case data.
void sendCommandBuffer(UINT8 *buffer, UINT16 len)
UINT8 m_receiveBuffer[25000]
Low-Level receive buffer for all data (25000 should be enough for NAV300 Events)
void(* DisconnectFunction)(void *obj)
Definition: tcp.hpp:53
uint32_t UINT32
Definition: Mutex.hpp:15
SopasProtocol m_protocol
bool setReadCallbackFunction(Tcp::ReadFunction readFunction, void *obj)
Interface for TCP/IP.
void copyFrameToResposeBuffer(UINT32 frameLength)
Command Language ASCI.
UINT32 size() const
SopasProtocol m_protocol
bool isConnected()
Returns true if the tcp connection is established.
void(* ReadFunction)(void *obj, UINT8 *inputBuffer, UINT32 &numBytes)
Definition: tcp.hpp:49
Definition: tcp.hpp:30
UINT32 m_numberOfBytesInResponseBuffer
Number of bytes in buffer.
Command Language binary.
Object has been constructed. Use init() to go into CONNECTED state.
int32_t INT32
Unknown Command Language.
Mutex m_receiveDataMutex
Access mutex for buffer.
Class that represents a message that was sent by a sensor. (Event message)
UINT32 m_numberOfBytesInReceiveBuffer
Number of bytes in buffer.
void removeFrameFromReceiveBuffer(UINT32 frameLength)
void readCallbackFunction(UINT8 *buffer, UINT32 &numOfBytes)
~SopasEventMessage()
Destructor.
bool connect()
Connects to a sensor via tcp and reads the device name.
bool disconnect()
Closes the connection to the LMS. This is the opposite of init().
SopasProtocol
static void readCallbackFunctionS(void *obj, UINT8 *buffer, UINT32 &numOfBytes)
Function that will be called on incomming data via tcp.
SopasProtocol getProtocolType() const
uint8_t UINT8


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Tue Jul 9 2019 04:55:32