colab.hpp
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 //
3 // colab.hpp
4 //
5 // (c) 2011 SICK AG, Hamburg, Germany
6 //
7 
8 #ifndef COLAB_HPP
9 #define COLAB_HPP
10 
12 #include <memory.h> // for memread<>
13 
14 //
15 // Parser functions for a partly implementation of the CoLa-B
16 // protocol, needed for communication with SICK sensors.
17 //
18 namespace colab
19 {
20 
29 void addStringToBuffer(UINT8* buffer, UINT16& pos, const std::string& stringValue);
30 
31 
36 void addStringToBuffer(BYTE* buffer, const std::string& stringValue);
37 
38 
39 
44 std::string getStringFromBuffer(UINT8* buffer, UINT16& pos, UINT16 length);
45 
46 
47 
52 std::string getStringFromBuffer(BYTE*& buffer, UINT16 length);
53 
54 
55 
59 std::string getCommandStringFromBuffer(UINT8* buffer);
60 
61 
62 
63 
72 std::string getIdentifierFromBuffer(UINT8* buffer, UINT16& nextData, UINT16 bufferLength);
73 
74 
75 
79 void addFrameToBuffer(UINT8* sendBuffer, UINT8* cmdBuffer, UINT16* len);
80 
81 
82 // Returns the requested value. pos points then to the first byte of the next data field.
83 double getDoubleFromBuffer(UINT8* buffer, UINT16& pos);
84 
85 //
86 UINT16 decodeUINT16(BYTE* buffer);
87 
88 
89 
90 // -----------------------------------------------------------------------------------------------------------------
91 // TEMPLATE FUNCTIONS
92 // -----------------------------------------------------------------------------------------------------------------
93 
94 
95 // FIXME: use template functions from types.hpp instead !!! (memread/memwrite)
96 
104 template<typename T>
105 void addIntegerToBuffer(UINT8* buffer, UINT16& pos, T intValue)
106 {
107  UINT16 width = sizeof(T);
108 
109  for (int i = 0; i < width; i++)
110  {
111  buffer[pos+width-1-i] = (intValue >> (8 * i)) & 0xff; // BIG ENDIAN: width-1-i
112  }
113 
114  pos += width;
115 }
116 
117 
118 
124 template<typename T>
126 {
127  UINT16 width = sizeof(T);
128 // UINT8* buffer2 = buffer;
129 // T intValue = memread<T>(buffer2);
130 
131  T intValue = 0;
132 
133  for (int i = 0; i < width; i++)
134  {
135  intValue += buffer[pos+width-1-i] << (8 * i);
136  }
137 
138  pos += width;
139  return intValue;
140 }
141 
142 
143 
152 template<typename T>
153 void addFloatToBuffer(UINT8* buffer, UINT16& pos, T floatValue)
154 {
155  UINT16 width = sizeof(T);
156 
157 
158 
159  pos += width;
160 }
161 
162 
163 } // END namespace colab
164 #endif
UINT16
uint16_t UINT16
Definition: BasicDatatypes.hpp:73
UINT8
uint8_t UINT8
Definition: BasicDatatypes.hpp:75
colab::getIntegerFromBuffer
T getIntegerFromBuffer(UINT8 *buffer, UINT16 &pos)
Definition: colab.hpp:125
BasicDatatypes.hpp
BYTE
unsigned char BYTE
colab::addFrameToBuffer
void addFrameToBuffer(UINT8 *sendBuffer, UINT8 *cmdBuffer, UINT16 *len)
Definition: colab.cpp:99
colab::getStringFromBuffer
std::string getStringFromBuffer(UINT8 *buffer, UINT16 &pos, UINT16 length)
Definition: colab.cpp:39
colab::addFloatToBuffer
void addFloatToBuffer(UINT8 *buffer, UINT16 &pos, T floatValue)
Definition: colab.hpp:153
colab
Definition: colab.cpp:18
colab::addIntegerToBuffer
void addIntegerToBuffer(UINT8 *buffer, UINT16 &pos, T intValue)
Definition: colab.hpp:105
length
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
sick_scan_base.h
colab::getDoubleFromBuffer
double getDoubleFromBuffer(UINT8 *buffer, UINT16 &pos)
Definition: colab.cpp:129
colab::decodeUINT16
UINT16 decodeUINT16(BYTE *buffer)
Definition: colab.cpp:142
colab::addStringToBuffer
void addStringToBuffer(UINT8 *buffer, UINT16 &pos, const std::string &stringValue)
Definition: colab.cpp:21
colab::getCommandStringFromBuffer
std::string getCommandStringFromBuffer(UINT8 *buffer)
Definition: colab.cpp:56
colab::getIdentifierFromBuffer
std::string getIdentifierFromBuffer(UINT8 *buffer, UINT16 &nextData, UINT16 bufferLength)
Definition: colab.cpp:61


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:07