sdk_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 LIVOX_SDK_PROTOCOL_H_
26 #define LIVOX_SDK_PROTOCOL_H_
27 
28 #include <stdint.h>
29 #include "FastCRC/FastCRC.h"
30 #include "protocol.h"
31 
32 namespace livox_ros {
34 
35 #pragma pack(1)
36 
37 typedef struct {
44 } SdkPreamble;
45 
46 typedef struct {
55  uint8_t data[1];
56 } SdkPacket;
57 
58 #pragma pack()
59 
60 class SdkProtocol : public Protocol {
61  public:
62  SdkProtocol(uint16_t seed16, uint32_t seed32);
63  ~SdkProtocol() = default;
64 
65  int32_t ParsePacket(const uint8_t *i_buf, uint32_t i_len,
66  CommPacket *o_packet) override;
67 
68  int32_t Pack(uint8_t *o_buf, uint32_t o_buf_size, uint32_t *o_len,
69  const CommPacket &i_packet) override;
70 
71  uint32_t GetPreambleLen() override;
72 
73  uint32_t GetPacketWrapperLen() override;
74 
75  uint32_t GetPacketLen(const uint8_t *buf) override;
76 
77  int32_t CheckPreamble(const uint8_t *buf) override;
78 
79  int32_t CheckPacket(const uint8_t *buf) override;
80 
81  private:
84 };
85 } // namespace livox_ros
86 #endif // LIVOX_SDK_PROTOCOL_H_
SdkProtocol(uint16_t seed16, uint32_t seed32)
int32_t ParsePacket(const uint8_t *i_buf, uint32_t i_len, CommPacket *o_packet) override
unsigned short uint16_t
Definition: stdint.h:126
unsigned char uint8_t
Definition: stdint.h:125
uint32_t GetPacketWrapperLen() override
int32_t Pack(uint8_t *o_buf, uint32_t o_buf_size, uint32_t *o_len, const CommPacket &i_packet) override
unsigned int uint32_t
Definition: stdint.h:127
int32_t CheckPreamble(const uint8_t *buf) override
uint32_t GetPacketLen(const uint8_t *buf) override
int32_t CheckPacket(const uint8_t *buf) override
uint32_t GetPreambleLen() override
signed int int32_t
Definition: stdint.h:124


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