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 
26 class SopasEventMessage;
27 
28 class SopasAnswer;
29 
31 {
35 };
36 
37 
39 {
40 public:
41 
42 
44 
46 
47  bool init(std::string ipAddress,
48  unsigned short portNumber,
49  Tcp::DisconnectFunction disconnectFunction,
50  void *obj);
51 
53  void *obj);
54 
56  bool connect();
57 
59  bool isConnected();
60 
68  bool disconnect();
69 
70  void sendCommandBuffer(UINT8 *buffer, UINT16 len);
71 
72 private:
73  // TCP
74  bool openTcpConnection();
75 
76  void closeTcpConnection();
77 
79  static void readCallbackFunctionS(void *obj, UINT8 *buffer, UINT32 &numOfBytes);
80 
81  void readCallbackFunction(UINT8 *buffer, UINT32 &numOfBytes);
82 
84 
85  void processFrame(SopasEventMessage &frame);
86 
88 
89 
90  // Response buffer
94 
95  // Receive buffer
98 
99 
100 
101  // TCP
103  std::string m_ipAddress;
106 
107 
108  void copyFrameToResposeBuffer(UINT32 frameLength);
109 
110  void removeFrameFromReceiveBuffer(UINT32 frameLength);
111 
112 protected:
113  enum State
114  {
119  ,
123  // , RUNNING
124  };
125 
127 };
128 
131 {
132 public:
135 
138  {}
139 
147  SopasEventMessage(BYTE *buffer, SopasProtocol protocol, UINT32 frameLength);
148 
150  {
151  return m_protocol;
152  }
153 
154 
155  UINT32 size() const
156  {
157  return m_frameLength;
158  }
159 
161  UINT32 getPayLoadLength() const;
162 
163  std::string getCommandString() const;
164 
166  BYTE *getPayLoad();
167 
168  BYTE *getRawData();
169 
171  INT32 getVariableIndex();
172 
174  std::string getVariableName();
175 
176  bool isValid() const
177  { return (m_buffer != NULL); }
178 
179 private:
180  void detectEncoding();
181 
182  void detectMessageType();
183 
184 private:
188 };
189 
192 {
193 public:
195  SopasAnswer(const BYTE *answer, UINT32 answerLength);
196 
198  ~SopasAnswer();
199 
201  { return m_answerBuffer; }
202 
204  { return m_answerLength; }
205 
206  bool isValid()
207  { return (m_answerBuffer != NULL); }
208 
209 private:
212 };
213 
214 #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 Wed May 5 2021 03:05:48