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 "../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:158
void memwrite_UINT8(BYTE *&buffer, UINT8 value)
Definition: toolbox.cpp:586
char convertNibbleToHexChar(int value, bool useLowerCaseLetters=false)
Definition: toolbox.cpp:197
unsigned char BYTE
std::string toHexStringNbble(UINT8 val)
void memwrite_string(BYTE *&buffer, std::string text)
Definition: toolbox.cpp:604
std::string convertMeterToFeetAndInch(double m)
Definition: toolbox.cpp:125
uint16_t UINT16
std::string toHexString(UINT32 val)
Definition: toolbox.cpp:71
void convertUINT8toHexString(UINT8 byte, char *buffer)
Definition: toolbox.cpp:227
uint32_t UINT32
std::string toLower(const std::string &text)
Definition: toolbox.cpp:101
INT32 memread_INT32(BYTE *&buffer)
Definition: toolbox.cpp:485
void convertRGBtoHexString(UINT8 r, UINT8 g, UINT8 b, char *buffer)
Definition: toolbox.cpp:240
void stringToIpTarget(std::string ipAdrStr, UINT32 &ipAddress, UINT16 &port)
Definition: toolbox.cpp:365
std::string toString(UINT32 val)
Definition: toolbox.cpp:281
INT16 memread_INT16(BYTE *&buffer)
Definition: toolbox.cpp:474
int hexCharToValue(char c)
Definition: toolbox.cpp:173
void memwrite_INT16(BYTE *&buffer, INT16 value)
Definition: toolbox.cpp:567
void memwrite_float(BYTE *&buffer, float value)
Definition: toolbox.cpp:534
std::string ipAdrToString(UINT32 ipAddress)
Definition: toolbox.cpp:424
int32_t INT32
std::string doubleToString(double val, int digits_after_decimal_point)
Definition: toolbox.cpp:344
void traceBuffer(std::string headerText, BYTE *buffer, UINT32 len)
Definition: toolbox.cpp:20
UINT16 memread_UINT16(BYTE *&buffer)
Definition: toolbox.cpp:453
void memwrite_INT8(BYTE *&buffer, INT8 value)
Definition: toolbox.cpp:595
void memwrite_UINT32(BYTE *&buffer, UINT32 value)
Definition: toolbox.cpp:554
std::string memread_string(BYTE *&buffer, UINT16 length)
Definition: toolbox.cpp:498
int8_t INT8
void memwrite_UINT16(BYTE *&buffer, UINT16 value)
Definition: toolbox.cpp:576
int16_t INT16
void memwrite_INT32(BYTE *&buffer, INT32 value)
Definition: toolbox.cpp:545
double makeAngleValid(double angle)
Definition: toolbox.cpp:252
UINT32 memread_UINT32(BYTE *&buffer)
Definition: toolbox.cpp:439
float memread_float(BYTE *&buffer)
Definition: toolbox.cpp:523
std::string ipTargetToString(UINT32 ipAddress, UINT16 port)
Definition: toolbox.cpp:407
UINT8 memread_UINT8(BYTE *&buffer)
Definition: toolbox.cpp:464
uint8_t UINT8


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Sat Jun 8 2019 17:57:33