cola_converter.h
Go to the documentation of this file.
1 /*
2  * @brief sim_loc_cola_converter converts between Cola-ASCII and Cola-Binary telegrams.
3  * See Operation-Instruction-v1.1.0.241R.pdf, chapter 5.8 "About CoLa-A telegrams", page 46-48,
4  * Telegram-Listing-v1.1.0.241R.pdf, chapter 2.3.9 "Command: LocRequestTimestamp", page 21, and
5  * Technical_information_Telegram_Listing_NAV_LOC_en_IM0076556.PDF for further details about
6  * Cola telegrams.
7  *
8  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
9  * Copyright (C) 2019 SICK AG, Waldkirch
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * All rights reserved.
24  *
25  * Redistribution and use in source and binary forms, with or without
26  * modification, are permitted provided that the following conditions are met:
27  *
28  * * Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * * Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in the
32  * documentation and/or other materials provided with the distribution.
33  * * Neither the name of SICK AG nor the names of its
34  * contributors may be used to endorse or promote products derived from
35  * this software without specific prior written permission
36  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
37  * contributors may be used to endorse or promote products derived from
38  * this software without specific prior written permission
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
44  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
47  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50  * POSSIBILITY OF SUCH DAMAGE.
51  *
52  * Authors:
53  * Michael Lehning <michael.lehning@lehning.de>
54  *
55  * Copyright 2019 SICK AG
56  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
57  *
58  */
59 #ifndef __SIM_LOC_COLA_CONVERTER_H_INCLUDED
60 #define __SIM_LOC_COLA_CONVERTER_H_INCLUDED
61 
62 #include <cstdint>
63 #include <map>
64 #include <string>
65 #include <vector>
66 
67 #include "sick_scan/ros_wrapper.h"
68 
69 namespace sick_scan
70 {
79  {
80  public:
81 
87  static std::string ConvertColaAscii(const std::vector<uint8_t> & cola_telegram);
88 
95  static std::vector<uint8_t> ConvertColaAscii(const std::string & cola_telegram);
96 
107  static std::vector<uint8_t> ColaTelegramToColaBinary(const sick_scan::SickLocColaTelegramMsg & cola_telegram, int parameter_is_ascii = -1);
108 
121  static std::vector<uint8_t> ColaAsciiToColaBinary(const std::vector<uint8_t> & cola_telegram, int parameter_is_ascii = -1);
122 
131  static std::vector<uint8_t> ColaBinaryToColaAscii(const std::vector<uint8_t> & cola_telegram, bool parameter_to_ascii = true);
132 
139  static bool IsColaBinary(const std::vector<uint8_t> & cola_telegram);
140 
146  static uint32_t ColaBinaryTelegramLength(const std::vector<uint8_t> & cola_telegram);
147 
148  protected:
149 
150  /*
151  * member data
152  */
153 
154  static const std::string s_ascii_table[256];
155  static const std::map<std::string, uint8_t> s_ascii_map;
156 
157  }; // class ColaAsciiBinaryConverter
158 
159 } // namespace sick_scan
160 #endif // __SIM_LOC_COLA_CONVERTER_H_INCLUDED
static uint32_t ColaBinaryTelegramLength(const std::vector< uint8_t > &cola_telegram)
Decodes the header and returns the length of a Cola-Binary telegram.
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 { 0x...
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]...
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>"]:=0...
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.
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.
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.
static std::string ConvertColaAscii(const std::vector< uint8_t > &cola_telegram)
Converts and returns a Cola-ASCII telegram to string.
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.


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