protocol.h
Go to the documentation of this file.
1 //
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2019 Livox. All rights reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //
24 
25 #ifndef COMM_PROTOCOL_H_
26 #define COMM_PROTOCOL_H_
27 
28 #include <stdint.h>
29 
30 namespace livox_ros {
31 typedef struct CommPacket CommPacket;
32 
33 typedef int (*RequestPackCb)(CommPacket *packet);
34 
36 
38 
40 
42 
43 typedef enum {
48 
49 typedef struct CommPacket {
63 } CommPacket;
64 
66 typedef struct {
70 
72 typedef struct { void *data; } GpsProtocolConfig;
73 
74 typedef struct {
76  union {
79  } config;
81 
82 class Protocol {
83  public:
84  virtual ~Protocol() = default;
85 
86  virtual int32_t ParsePacket(const uint8_t *i_buf, uint32_t i_len,
87  CommPacket *o_packet) = 0;
88 
89  virtual int32_t Pack(uint8_t *o_buf, uint32_t o_buf_size, uint32_t *o_len,
90  const CommPacket &i_packet) = 0;
91 
92  virtual uint32_t GetPreambleLen() = 0;
93 
94  virtual uint32_t GetPacketWrapperLen() = 0;
95 
96  virtual uint32_t FindPacketLen(const uint8_t *buf, uint32_t buf_length) = 0;
97 
98  virtual uint32_t GetPacketLen(const uint8_t *buf) = 0;
99 
100  virtual int32_t CheckPreamble(const uint8_t *buf) = 0;
101 
102  virtual int32_t CheckPacket(const uint8_t *buf) = 0;
103 };
104 
105 } // namespace livox_ros
106 #endif // COMM_PROTOCOL_H_
ProtocolType
Definition: protocol.h:37
unsigned short uint16_t
Definition: stdint.h:126
uint32_t sub_sender
Definition: protocol.h:56
unsigned char uint8_t
Definition: stdint.h:125
uint32_t sub_receiver
Definition: protocol.h:58
int(* RequestPackCb)(CommPacket *packet)
Definition: protocol.h:33
uint8_t protocol_version
Definition: protocol.h:52
unsigned int uint32_t
Definition: stdint.h:127
FindLengthResult
Definition: protocol.h:43
GpsProtocolConfig gps
Definition: protocol.h:78
SdkProtocolConfig sdk
Definition: protocol.h:77
signed int int32_t
Definition: stdint.h:124
struct CommPacket CommPacket
Definition: protocol.h:31


livox_ros_driver
Author(s): Livox Dev Team
autogenerated on Mon Mar 15 2021 02:40:46