Static Public Member Functions | Static Protected Attributes | List of all members
sick_scan::ColaAsciiBinaryConverter Class Reference

class ColaAsciiBinaryConverter converts between Cola-ASCII and Cola-Binary telegrams. See Operation-Instruction-v1.1.0.241R.pdf, chapter 5.8 "About CoLa-A telegrams", page 46-48, Telegram-Listing-v1.1.0.241R.pdf, chapter 2.3.9 "Command: LocRequestTimestamp", page 21, and Technical_information_Telegram_Listing_NAV_LOC_en_IM0076556.PDF for further details about Cola telegrams. More...

#include <cola_converter.h>

Static Public Member Functions

static std::vector< uint8_t > ColaAsciiToColaBinary (const std::vector< uint8_t > &cola_telegram, int parameter_is_ascii=-1)
 Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary. More...
 
static uint32_t ColaBinaryTelegramLength (const std::vector< uint8_t > &cola_telegram)
 Decodes the header and returns the length of a Cola-Binary telegram. More...
 
static std::vector< uint8_t > ColaBinaryToColaAscii (const std::vector< uint8_t > &cola_telegram, bool parameter_to_ascii=true)
 Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary. More...
 
static std::vector< uint8_t > ColaTelegramToColaBinary (const sick_scan::SickLocColaTelegramMsg &cola_telegram, int parameter_is_ascii=-1)
 Converts and returns a Cola telegram to Cola-Binary. More...
 
static std::vector< uint8_t > ConvertColaAscii (const std::string &cola_telegram)
 Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary. More...
 
static std::string ConvertColaAscii (const std::vector< uint8_t > &cola_telegram)
 Converts and returns a Cola-ASCII telegram to string. More...
 
static bool IsColaBinary (const std::vector< uint8_t > &cola_telegram)
 Returns true for Cola-Binary, if a given telegram is Cola-Binary encoded and starts with 4 Bytes { 0x02, 0x02, 0x02, 0x02 }, otherwise false (Cola-ASCII telegram) More...
 

Static Protected Attributes

static const std::map< std::string, uint8_t > s_ascii_map
 static ascii map to convert ascii to binary, f.e. s_ascii_map["<STX>"]:=0x02, s_ascii_map["<ETX>"]:=0x03, s_ascii_map["A"]:=0x41 and so on More...
 
static const std::string s_ascii_table [256]
 static ascii table to convert binary to ascii, f.e. s_ascii_table[0x02]:="<STX>", s_ascii_table[0x03]:="<ETX>", s_ascii_table[0x41]:="A" and so on More...
 

Detailed Description

class ColaAsciiBinaryConverter converts between Cola-ASCII and Cola-Binary telegrams. See Operation-Instruction-v1.1.0.241R.pdf, chapter 5.8 "About CoLa-A telegrams", page 46-48, Telegram-Listing-v1.1.0.241R.pdf, chapter 2.3.9 "Command: LocRequestTimestamp", page 21, and Technical_information_Telegram_Listing_NAV_LOC_en_IM0076556.PDF for further details about Cola telegrams.

Definition at line 78 of file cola_converter.h.

Member Function Documentation

◆ ColaAsciiToColaBinary()

std::vector< uint8_t > sick_scan::ColaAsciiBinaryConverter::ColaAsciiToColaBinary ( const std::vector< uint8_t > &  cola_telegram,
int  parameter_is_ascii = -1 
)
static

Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary.

Parameters
[in]cola_telegramCola-ASCII telegram, f.e. { 0x02, 0x73, 0x4D, 0x4E, 0x20, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4D, 0x6F, 0x64, 0x65, 0x20, 0x33, 0x20, 0x46, 0x34, 0x37, 0x32, 0x34, 0x37, 0x34, 0x34, 0x03 } ("<STX>sMN SetAccessMode 3 F4724744<ETX>")
[in]parameter_is_asciiCommand parameter given in ascii (f.e. if 1, a parameter 0x31 == ASCII-"1" will be converted to 0x01 (default), otherwise to 0x01)
[in]parameter_is_asciiCommand parameter given in ascii (f.e. if 1, a parameter 0x31 == ASCII-"1" will be converted to 0x01 (default), otherwise to 0x01) parameter_is_ascii = 1: Command parameter given in ascii and will be converted to binary parameter_is_ascii = 0: Command parameter given binary and will be copied to binary output parameter_is_ascii = -1: Auto determination (1. assumption is true, 2. assumption is false in case of errors)
Returns
Cola-Binary telegram
Parameters
[in]cola_telegramCola-ASCII telegram, f.e. { 0x02, 0x73, 0x4D, 0x4E, 0x20, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4D, 0x6F, 0x64, 0x65, 0x20, 0x33, 0x20, 0x46, 0x34, 0x37, 0x32, 0x34, 0x37, 0x34, 0x34, 0x03 } ("<STX>sMN SetAccessMode 3 F4724744<ETX>")
[in]parameter_is_asciiCommand parameter given in ascii (f.e. if 1, a parameter 0x31 == ASCII-"1" will be converted to 0x01 (default), otherwise to 0x01) parameter_is_ascii = 1: Command parameter given in ascii and will be converted to binary parameter_is_ascii = 0: Command parameter given binary and will be copied to binary output parameter_is_ascii = -1: Auto determination (1. assumption is true, 2. assumption is false in case of errors)
Returns
Cola-Binary telegram

Definition at line 162 of file cola_converter.cpp.

◆ ColaBinaryTelegramLength()

uint32_t sick_scan::ColaAsciiBinaryConverter::ColaBinaryTelegramLength ( const std::vector< uint8_t > &  cola_telegram)
static

Decodes the header and returns the length of a Cola-Binary telegram.

Parameters
[in]cola_telegramCola-Binary telegram
Returns
expected telegram length incl. header, payload and crc, or 0 in case of errors.

Definition at line 354 of file cola_converter.cpp.

◆ ColaBinaryToColaAscii()

std::vector< uint8_t > sick_scan::ColaAsciiBinaryConverter::ColaBinaryToColaAscii ( const std::vector< uint8_t > &  cola_telegram,
bool  parameter_to_ascii = true 
)
static

Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary.

Parameters
[in]cola_telegramCola-Binary telegram
[in]parameter_to_asciiConversion of command parameter to ascii (f.e. if true, a parameter 0x01 will be converted to 0x31 == ASCII-"1" (default), otherwise to 0x01)
Returns
Cola-ASCII telegram, f.e. { 0x02, 0x73, 0x4D, 0x4E, 0x20, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4D, 0x6F, 0x64, 0x65, 0x20, 0x33, 0x20, 0x46, 0x34, 0x37, 0x32, 0x34, 0x37, 0x34, 0x34, 0x03 } ("<STX>sMN SetAccessMode 3 F4724744<ETX>")
Parameters
[in]cola_telegramCola-Binary telegram
[in]parameter_to_asciiConversion of command parameter to ascii (f.e. if true, a parameter 0x01 == ASCII-"1" will be converted to 0x31 (default), otherwise to 0x01)
Returns
Cola-ASCII telegram, f.e. { 0x02, 0x73, 0x4D, 0x4E, 0x20, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4D, 0x6F, 0x64, 0x65, 0x20, 0x33, 0x20, 0x46, 0x34, 0x37, 0x32, 0x34, 0x37, 0x34, 0x34, 0x03 } ("<STX>sMN SetAccessMode 3 F4724744<ETX>")

Definition at line 267 of file cola_converter.cpp.

◆ ColaTelegramToColaBinary()

std::vector< uint8_t > sick_scan::ColaAsciiBinaryConverter::ColaTelegramToColaBinary ( const sick_scan::SickLocColaTelegramMsg &  cola_msg,
int  parameter_is_ascii = -1 
)
static

Converts and returns a Cola telegram to Cola-Binary.

Parameters
[in]cola_telegramCola telegram,
[in]parameter_is_asciiCommand parameter given in ascii (f.e. if 1, a parameter 0x31 == ASCII-"1" will be converted to 0x01 (default), otherwise to 0x01)
[in]parameter_is_asciiCommand parameter given in ascii (f.e. if 1, a parameter 0x31 == ASCII-"1" will be converted to 0x01 (default), otherwise to 0x01) parameter_is_ascii = 1: Command parameter given in ascii and will be converted to binary parameter_is_ascii = 0: Command parameter given binary and will be copied to binary output parameter_is_ascii = -1: Auto determination (1. assumption is true, 2. assumption is false in case of errors)
Returns
Cola-Binary telegram

Definition at line 185 of file cola_converter.cpp.

◆ ConvertColaAscii() [1/2]

std::vector< uint8_t > sick_scan::ColaAsciiBinaryConverter::ConvertColaAscii ( const std::string &  cola_telegram)
static

Converts and returns a Cola telegram from Cola-ASCII to Cola-Binary.

Parameters
[in]cola_telegramCola-ASCII string, f.e. "<STX>sMN SetAccessMode 3 F4724744<ETX>"
Returns
Cola-ASCII telegram, f.e. { 0x02, 0x73, 0x4D, 0x4E, 0x20, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4D, 0x6F, 0x64, 0x65, 0x20, 0x33, 0x20, 0x46, 0x34, 0x37, 0x32, 0x34, 0x37, 0x34, 0x34, 0x03 }

Definition at line 122 of file cola_converter.cpp.

◆ ConvertColaAscii() [2/2]

std::string sick_scan::ColaAsciiBinaryConverter::ConvertColaAscii ( const std::vector< uint8_t > &  cola_telegram)
static

Converts and returns a Cola-ASCII telegram to string.

Parameters
[in]cola_telegramCola-ASCII telegram, starting with 0x02 and ending with 0x03
Returns
Cola-ASCII string, f.e. "<STX>sMN SetAccessMode 3 F4724744<ETX>"

Definition at line 105 of file cola_converter.cpp.

◆ IsColaBinary()

bool sick_scan::ColaAsciiBinaryConverter::IsColaBinary ( const std::vector< uint8_t > &  cola_telegram)
static

Returns true for Cola-Binary, if a given telegram is Cola-Binary encoded and starts with 4 Bytes { 0x02, 0x02, 0x02, 0x02 }, otherwise false (Cola-ASCII telegram)

Parameters
[in]cola_telegramCola telegram (Cola-ASCII to Cola-Binary)
Returns
true for Cola-Binary, false for Cola-ASCII

Definition at line 342 of file cola_converter.cpp.

Member Data Documentation

◆ s_ascii_map

const std::map< std::string, uint8_t > sick_scan::ColaAsciiBinaryConverter::s_ascii_map
staticprotected
Initial value:
=
{
{"<SOH>", 0x01}, {"<STX>", 0x02}, {"<ETX>", 0x03}, {"<EOT>", 0x04}, {"<ENQ>", 0x05}, {"<ACK>", 0x06}, {"<BEL>", 0x07}, {"\b", 0x08}, {"<HT>", 0x09},
{"\n", 0x0A}, {"<VT>", 0x0B}, {"<FF>", 0x0C}, {"\n", 0x0D}, {"<SO>", 0x0E}, {"<SI>", 0x0F}, {"<DLE>", 0x10}, {"<DC1>", 0x11}, {"<DC2>", 0x12},
{"<DC3>", 0x13}, {"<DC4>", 0x14}, {"<NAK>", 0x15}, {"<SYN>", 0x16}, {"<ETB>", 0x17}, {"<CAN>", 0x18}, {"<EM>", 0x19}, {"<SUB>", 0x1A}, {"<ESC>", 0x1B},
{"<FS>", 0x1C}, {"<GS>", 0x1D}, {"<RS>", 0x1E}, {"<US>", 0x1F}, {" ", 0x20}, {"!", 0x21}, {"\"", 0x22}, {"#", 0x23}, {"$", 0x24}, {"%", 0x25}, {"&", 0x26},
{"'", 0x27}, {"(", 0x28}, {")", 0x29}, {"*", 0x2A}, {"+", 0x2B}, {",", 0x2C}, {"-", 0x2D}, {".", 0x2E}, {"/", 0x2F},
{"0", 0x30}, {"1", 0x31}, {"2", 0x32}, {"3", 0x33}, {"4", 0x34}, {"5", 0x35}, {"6", 0x36}, {"7", 0x37}, {"8", 0x38}, {"9", 0x39}, {":", 0x3A}, {";", 0x3B}, {"=", 0x3D}, {"?", 0x3F}, {"@", 0x40},
{"A", 0x41}, {"B", 0x42}, {"C", 0x43}, {"D", 0x44}, {"E", 0x45}, {"F", 0x46}, {"G", 0x47}, {"H", 0x48}, {"I", 0x49}, {"J", 0x4A}, {"K", 0x4B}, {"L", 0x4C}, {"M", 0x4D}, {"N", 0x4E}, {"O", 0x4F},
{"P", 0x50}, {"Q", 0x51}, {"R", 0x52}, {"S", 0x53}, {"T", 0x54}, {"U", 0x55}, {"V", 0x56}, {"W", 0x57}, {"X", 0x58}, {"Y", 0x59}, {"Z", 0x5A}, {"[", 0x5B}, {"\\", 0x5C}, {"]", 0x5D}, {"^", 0x5E}, {"_", 0x5F}, {"`", 0x60},
{"a", 0x61}, {"b", 0x62}, {"c", 0x63}, {"d", 0x64}, {"e", 0x65}, {"f", 0x66}, {"g", 0x67}, {"h", 0x68}, {"i", 0x69}, {"j", 0x6A}, {"k", 0x6B}, {"l", 0x6C}, {"m", 0x6D}, {"n", 0x6E}, {"o", 0x6F},
{"p", 0x70}, {"q", 0x71}, {"r", 0x72}, {"s", 0x73}, {"t", 0x74}, {"u", 0x75}, {"v", 0x76}, {"w", 0x77}, {"x", 0x78}, {"y", 0x79}, {"z", 0x7A}, {"{", 0x7B}, {"|", 0x7C}, {"}", 0x7D}, {"~", 0x7E}, {"<DEL>", 0x7F}
}

static ascii map to convert ascii to binary, f.e. s_ascii_map["<STX>"]:=0x02, s_ascii_map["<ETX>"]:=0x03, s_ascii_map["A"]:=0x41 and so on

Definition at line 155 of file cola_converter.h.

◆ s_ascii_table

const std::string sick_scan::ColaAsciiBinaryConverter::s_ascii_table
staticprotected
Initial value:
=
{
"", "<SOH>", "<STX>", "<ETX>", "<EOT>", "<ENQ>", "<ACK>", "<BEL>", "\b", "<HT>", "\n", "<VT>", "<FF>", "\n",
"<SO>", "<SI>", "<DLE>", "<DC1>", "<DC2>", "<DC3>", "<DC4>", "<NAK>", "<SYN>", "<ETB>", "<CAN>", "<EM>", "<SUB>", "<ESC>", "<FS>", "<GS>", "<RS>", "<US>",
" ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "<DEL>",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", ""
}

static ascii table to convert binary to ascii, f.e. s_ascii_table[0x02]:="<STX>", s_ascii_table[0x03]:="<ETX>", s_ascii_table[0x41]:="A" and so on

Definition at line 154 of file cola_converter.h.


The documentation for this class was generated from the following files:


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19