rplidar_protocol.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * RPLIDAR SDK
  3. *
  4. * Copyright (c) 2009 - 2014 RoboPeak Team
  5. * http://www.robopeak.com
  6. * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
  7. * http://www.slamtec.com
  8. *
  9. */
  10. /*
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * 1. Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. *
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  23. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  24. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  28. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  30. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  31. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. */
  34. #pragma once
  35. // RP-Lidar Input Packets
  36. #define RPLIDAR_CMD_SYNC_BYTE 0xA5
  37. #define RPLIDAR_CMDFLAG_HAS_PAYLOAD 0x80
  38. #define RPLIDAR_ANS_SYNC_BYTE1 0xA5
  39. #define RPLIDAR_ANS_SYNC_BYTE2 0x5A
  40. #define RPLIDAR_ANS_PKTFLAG_LOOP 0x1
  41. #define RPLIDAR_ANS_HEADER_SIZE_MASK 0x3FFFFFFF
  42. #define RPLIDAR_ANS_HEADER_SUBTYPE_SHIFT (30)
  43. #if defined(_WIN32)
  44. #pragma pack(1)
  45. #endif
  46. typedef struct _rplidar_cmd_packet_t {
  47. _u8 syncByte; //must be RPLIDAR_CMD_SYNC_BYTE
  48. _u8 cmd_flag;
  49. _u8 size;
  50. _u8 data[0];
  51. } __attribute__((packed)) rplidar_cmd_packet_t;
  52. typedef struct _rplidar_ans_header_t {
  53. _u8 syncByte1; // must be RPLIDAR_ANS_SYNC_BYTE1
  54. _u8 syncByte2; // must be RPLIDAR_ANS_SYNC_BYTE2
  55. _u32 size_q30_subtype; // see _u32 size:30; _u32 subType:2;
  56. _u8 type;
  57. } __attribute__((packed)) rplidar_ans_header_t;
  58. #if defined(_WIN32)
  59. #pragma pack()
  60. #endif