Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef COLAB_HPP
00008 #define COLAB_HPP
00009
00010 #include "sick_scan/tcp/BasicDatatypes.hpp"
00011 #include <memory.h>
00012
00013
00014
00015
00016
00017 namespace colab
00018 {
00019
00028 void addStringToBuffer(UINT8* buffer, UINT16& pos, const std::string& stringValue);
00029
00030
00035 void addStringToBuffer(BYTE* buffer, const std::string& stringValue);
00036
00037
00038
00043 std::string getStringFromBuffer(UINT8* buffer, UINT16& pos, UINT16 length);
00044
00045
00046
00051 std::string getStringFromBuffer(BYTE*& buffer, UINT16 length);
00052
00053
00054
00058 std::string getCommandStringFromBuffer(UINT8* buffer);
00059
00060
00061
00062
00071 std::string getIdentifierFromBuffer(UINT8* buffer, UINT16& nextData, UINT16 bufferLength);
00072
00073
00074
00078 void addFrameToBuffer(UINT8* sendBuffer, UINT8* cmdBuffer, UINT16* len);
00079
00080
00081
00082 double getDoubleFromBuffer(UINT8* buffer, UINT16& pos);
00083
00084
00085 UINT16 decodeUINT16(BYTE* buffer);
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00103 template<typename T>
00104 void addIntegerToBuffer(UINT8* buffer, UINT16& pos, T intValue)
00105 {
00106 UINT16 width = sizeof(T);
00107
00108 for (int i = 0; i < width; i++)
00109 {
00110 buffer[pos+width-1-i] = (intValue >> (8 * i)) & 0xff;
00111 }
00112
00113 pos += width;
00114 }
00115
00116
00117
00123 template<typename T>
00124 T getIntegerFromBuffer(UINT8* buffer, UINT16& pos)
00125 {
00126 UINT16 width = sizeof(T);
00127
00128
00129
00130 T intValue = 0;
00131
00132 for (int i = 0; i < width; i++)
00133 {
00134 intValue += buffer[pos+width-1-i] << (8 * i);
00135 }
00136
00137 pos += width;
00138 return intValue;
00139 }
00140
00141
00142
00151 template<typename T>
00152 void addFloatToBuffer(UINT8* buffer, UINT16& pos, T floatValue)
00153 {
00154 UINT16 width = sizeof(T);
00155
00156
00157
00158 pos += width;
00159 }
00160
00161
00162 }
00163 #endif