toolbox.hpp
Go to the documentation of this file.
1 
5 #ifndef TOOLBOX_HPP
6 #define TOOLBOX_HPP
7 
8 #include <stdio.h> /* for printf() and fprintf() */
9 #include <sys/socket.h> /* for socket(), bind(), and connect() */
10 #include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */
11 #include <stdlib.h> /* for atoi() and exit() */
12 #include <string.h> /* for memset() */
13 #include "sick_scan/tcp/BasicDatatypes.hpp" // for PI
14 
15 // Konvertierung eines Hex-Zeichens -> Zahlenwert.
16 int hexCharToValue(char c);
17 
18 // Konvertierung Zahlenwert (0-15) -> Hex-Zeichen.
19 char convertNibbleToHexChar(int value, bool useLowerCaseLetters = false);
20 
21 // Konvertiert Byte (0-255) in Hex-String 00-FF
22 void convertUINT8toHexString(UINT8 byte, char* buffer);
23 
24 // Konvertiert 3 Byte-Werte (RGB) in einen char-String
25 void convertRGBtoHexString(UINT8 r, UINT8 g, UINT8 b, char* buffer);
26 
27 // Bringt den Winkel in den Bereich ]PI..-PI]
28 double makeAngleValid(double angle);
29 
30 // Konvertiere eine IP-Adresse (IPv4)+Port in einen String
31 std::string ipTargetToString(UINT32 ipAddress, UINT16 port);
32 // Konvertiere eine reine IP-Adresse (IPv4), ohne Port, in einen String
33 std::string ipAdrToString(UINT32 ipAddress);
34 
35 // Konvertiere einen String (IP-Adresse (IPv4)+Port) in seine Bestandteile.
36 // Enthaelt der String keinen Port, bleibt dieser unveraendert.
37 void stringToIpTarget(std::string ipAdrStr, UINT32& ipAddress, UINT16& port);
38 
39 // Konvertiere eine Integer-Zahl in einen Hex-String
40 std::string toHexString(UINT32 val);
41 std::string toHexString(UINT16 val);
42 std::string toHexString(UINT8 val);
43 std::string toHexStringNbble(UINT8 val);
44 
45 // Konvertiere eine Integer-Zahl in einen String
46 std::string toString(UINT32 val);
47 std::string toString(INT32 val);
48 #if INTPTR_MAX != INT32_MAX
49 std::string toString(size_t val);
50 #endif
51 
52 // Konvertiere eine Gleitkomma-Zahl in einen String
53 std::string toString(double val, int digits_after_decimal_point);
54 std::string doubleToString(double val, int digits_after_decimal_point);
55 std::string doubleToString(double val, int digits_before_decimal_point, int digits_after_decimal_point);
56 
57 // Converts a length in [m] to a string with feet and inches. Intended for text output.
58 std::string convertMeterToFeetAndInch(double m);
59 
60 // Konvertiere einen String in eine Zahl
61 UINT16 fromString(const std::string& text);
62 
63 // Konvertiere einen String in Kleinbuchstaben
64 std::string toLower(const std::string& text);
65 
66 //
67 // Write a binary trace output, e.g. of buffer contents.
68 // Can be used for debugging.
69 //
70 void traceBuffer(std::string headerText, BYTE* buffer, UINT32 len);
71 
72 //
73 // Access functions for binary data in buffers (big endian format)
74 //
75 UINT32 memread_UINT32(BYTE*& buffer);
76 UINT16 memread_UINT16(BYTE*& buffer);
77 UINT8 memread_UINT8(BYTE*& buffer);
78 INT32 memread_INT32(BYTE*& buffer);
79 INT16 memread_INT16(BYTE*& buffer);
80 float memread_float(BYTE*& buffer);
81 std::string memread_string(BYTE*& buffer, UINT16 length);
82 
83 void memwrite_float(BYTE*& buffer, float value);
84 void memwrite_INT32(BYTE*& buffer, INT32 value);
85 void memwrite_UINT32(BYTE*& buffer, UINT32 value);
86 void memwrite_INT16(BYTE*& buffer, INT16 value);
87 void memwrite_UINT16(BYTE*& buffer, UINT16 value);
88 void memwrite_INT8(BYTE*& buffer, INT8 value);
89 void memwrite_UINT8(BYTE*& buffer, UINT8 value);
90 void memwrite_string(BYTE*& buffer, std::string text);
91 
92 #endif // TOOLBOX_HPP
UINT16 fromString(const std::string &text)
Definition: toolbox.cpp:166
void memwrite_UINT8(BYTE *&buffer, UINT8 value)
Definition: toolbox.cpp:594
char convertNibbleToHexChar(int value, bool useLowerCaseLetters=false)
Definition: toolbox.cpp:205
std::string toHexStringNbble(UINT8 val)
void memwrite_string(BYTE *&buffer, std::string text)
Definition: toolbox.cpp:612
std::string convertMeterToFeetAndInch(double m)
Definition: toolbox.cpp:133
unsigned char BYTE
uint16_t UINT16
std::string toHexString(UINT32 val)
Definition: toolbox.cpp:79
void convertUINT8toHexString(UINT8 byte, char *buffer)
Definition: toolbox.cpp:235
uint32_t UINT32
std::string toLower(const std::string &text)
Definition: toolbox.cpp:109
INT32 memread_INT32(BYTE *&buffer)
Definition: toolbox.cpp:493
void convertRGBtoHexString(UINT8 r, UINT8 g, UINT8 b, char *buffer)
Definition: toolbox.cpp:248
void stringToIpTarget(std::string ipAdrStr, UINT32 &ipAddress, UINT16 &port)
Definition: toolbox.cpp:373
std::string toString(UINT32 val)
Definition: toolbox.cpp:289
INT16 memread_INT16(BYTE *&buffer)
Definition: toolbox.cpp:482
int hexCharToValue(char c)
Definition: toolbox.cpp:181
void memwrite_INT16(BYTE *&buffer, INT16 value)
Definition: toolbox.cpp:575
void memwrite_float(BYTE *&buffer, float value)
Definition: toolbox.cpp:542
std::string ipAdrToString(UINT32 ipAddress)
Definition: toolbox.cpp:432
int32_t INT32
std::string doubleToString(double val, int digits_after_decimal_point)
Definition: toolbox.cpp:352
void traceBuffer(std::string headerText, BYTE *buffer, UINT32 len)
Definition: toolbox.cpp:28
UINT16 memread_UINT16(BYTE *&buffer)
Definition: toolbox.cpp:461
void memwrite_INT8(BYTE *&buffer, INT8 value)
Definition: toolbox.cpp:603
void memwrite_UINT32(BYTE *&buffer, UINT32 value)
Definition: toolbox.cpp:562
std::string memread_string(BYTE *&buffer, UINT16 length)
Definition: toolbox.cpp:506
int8_t INT8
void memwrite_UINT16(BYTE *&buffer, UINT16 value)
Definition: toolbox.cpp:584
int16_t INT16
void memwrite_INT32(BYTE *&buffer, INT32 value)
Definition: toolbox.cpp:553
double makeAngleValid(double angle)
Definition: toolbox.cpp:260
UINT32 memread_UINT32(BYTE *&buffer)
Definition: toolbox.cpp:447
float memread_float(BYTE *&buffer)
Definition: toolbox.cpp:531
std::string ipTargetToString(UINT32 ipAddress, UINT16 port)
Definition: toolbox.cpp:415
UINT8 memread_UINT8(BYTE *&buffer)
Definition: toolbox.cpp:472
uint8_t UINT8


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48