You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
6.0 KiB

​
​
​
​
​
6 years ago
6 years ago
​
6 years ago
​
​
​
​
​
​
5 years ago
​
​
​
​
6 years ago
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
5 years ago
​
​
​
​
6 years ago
5 years ago
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
5 years ago
​
​
5 years ago
5 years ago
​
​
6 years ago
5 years ago
​
​
​
​
​
​
​
​
​
6 years ago
​
5 years ago
5 years ago
​
6 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
6 years ago
​
  1. #ifndef __PROTOCOL_LRF_3D_INTERNAL_MASTER_SERVER_COMMUNICATION__
  2. #define __PROTOCOL_LRF_3D_INTERNAL_MASTER_SERVER_COMMUNICATION__
  3. //aliona
  4. //https://www.pornhub.com/view_video.php?viewkey=ph5dffcb1983567
  5. #include <queue>
  6. #include "protocol.h"
  7. #include "../../hardware/soc/general/3DLRF.h"
  8. #ifdef PRU_SLAVE
  9. #define SEND_TAG 0x00
  10. #else
  11. #define SEND_TAG 0x80
  12. #endif
  13. #define TWI_TARGET_QUEUE_SIZE 128
  14. #define TWI_CMD_INDEX 3
  15. #define TWI_PLS_INDEX 4
  16. #define TWI_MAX_PACKAGE_SIZE_BYTES 0x8002
  17. #define TWI_MAX_PAYLOAD_SIZE_BYTES 0x7fff
  18. typedef enum E_TWIN_COMMAND{
  19. TWC_NO_COMMAND = 0,
  20. TWC_SET_CMD_MODE = 1,
  21. TWC_SET_EVT_MODE,
  22. TWC_ACK_CMD,
  23. TWC_GET_MODE,
  24. TWC_CURRENT_MODE,
  25. TWC_GET_STATUS,
  26. TWC_CURRENT_STATUS,
  27. TWC_GET_CONFIG,
  28. TWC_CURRENT_CONFIG,
  29. TWC_SET_CONFIG,
  30. TWC_GET_VERSION,
  31. TWC_CURRENT_VERSION,
  32. TWC_GET_SHADOW,
  33. TWC_CURRENT_SHADOW,
  34. TWC_SET_SHADOW,
  35. TWC_SH_DATA,
  36. TWC_GET_THRESHOLD,
  37. TWC_TH_DATA,
  38. TWC_INIT_TSINC,
  39. TWC_TSINC_1,
  40. TWC_TSINC_2,
  41. TWC_PUSH_TARGET,
  42. TWC_DO_REBOOT
  43. } TWIN_COMMAND;
  44. typedef struct S_TWI_CMD_CONTAINER{
  45. TWIN_COMMAND CMD;
  46. size_t SIZE;
  47. void * DATA;
  48. }TWI_CMD_CONTAINER;
  49. typedef std::queue<TWI_CMD_CONTAINER *> TWI_CMD_QUEUE;
  50. #define TWI_STATUS_ERROR_MASK 0x000000ff
  51. #define TWI_STATUS_TARGET_MASK 0x0000ff00
  52. #define TWI_STATUS_KERNEL_MASK 0xffff0000
  53. #define TWI_STATUS_MASTER_KERNEL_MASK 0x00ff0000
  54. #define TWI_STATUS_SLAVE_KERNEL_MASK 0xff000000
  55. #define TWI_STATUS_KERNEL_00_RDY 0x00000001
  56. #define TWI_STATUS_KERNEL_01_RDY 0x00000002
  57. #define TWI_STATUS_KERNEL_02_RDY 0x00000004
  58. #define TWI_STATUS_KERNEL_03_RDY 0x00000008
  59. #define TWI_STATUS_KERNEL_04_RDY 0x00000010
  60. #define TWI_STATUS_KERNEL_05_RDY 0x00000020
  61. #define TWI_STATUS_KERNEL_06_RDY 0x00000040
  62. #define TWI_STATUS_KERNEL_07_RDY 0x00000080
  63. #define TWI_STATUS_KERNEL_08_RDY 0x00000100
  64. #define TWI_STATUS_KERNEL_09_RDY 0x00000200
  65. #define TWI_STATUS_KERNEL_10_RDY 0x00000400
  66. #define TWI_STATUS_KERNEL_11_RDY 0x00000800
  67. #define TWI_STATUS_KERNEL_12_RDY 0x00001000
  68. #define TWI_STATUS_KERNEL_13_RDY 0x00002000
  69. #define TWI_STATUS_KERNEL_14_RDY 0x00004000
  70. #define TWI_STATUS_KERNEL_15_RDY 0x00008000
  71. #define TWI_STATUS_KERNEL_16_RDY 0x00010000
  72. #define TWI_STATUS_KERNEL_17_RDY 0x00020000
  73. #define TWI_STATUS_KERNEL_18_RDY 0x00040000
  74. #define TWI_STATUS_KERNEL_19_RDY 0x00080000
  75. #define TWI_STATUS_KERNEL_20_RDY 0x00100000
  76. #define TWI_STATUS_KERNEL_21_RDY 0x00200000
  77. #define TWI_STATUS_KERNEL_22_RDY 0x00400000
  78. #define TWI_STATUS_KERNEL_23_RDY 0x00800000
  79. #define TWI_STATUS_KERNEL_24_RDY 0x01000000
  80. #define TWI_STATUS_KERNEL_25_RDY 0x02000000
  81. #define TWI_STATUS_KERNEL_26_RDY 0x04000000
  82. #define TWI_STATUS_KERNEL_27_RDY 0x08000000
  83. #define TWI_STATUS_KERNEL_28_RDY 0x10000000
  84. #define TWI_STATUS_KERNEL_29_RDY 0x20000000
  85. #define TWI_STATUS_KERNEL_30_RDY 0x40000000
  86. #define TWI_STATUS_KERNEL_31_RDY 0x80000000
  87. class protocolInternalLRF3D: public protocolParser {
  88. private:
  89. basicLogCollection * m_pLog;
  90. protected:
  91. int packetChecker( U8 *Buffer, size_t BufferSize );
  92. protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize );
  93. inline int FinishUpPackage( U8 *Buffer, size_t Size ){
  94. Buffer[0] = 0xAA;
  95. Buffer[1] = ((Size - 3) >> 8) | SEND_TAG;
  96. Buffer[2] = (Size - 3) & 0xFF;
  97. Buffer[Size] = checksumLGS(Buffer, Size);
  98. return Size + 1;
  99. };
  100. bool sendACK( TWIN_COMMAND ACK_CMD );
  101. bool sendPlainCMD( TWIN_COMMAND ACK_CMD );
  102. public:
  103. protocolInternalLRF3D();
  104. virtual ~protocolInternalLRF3D();
  105. virtual bool create(){ return protocolParser::create(); };
  106. };
  107. #ifdef PRU_SLAVE
  108. class protocolInternalLRF3D_SLAVE: public protocolInternalLRF3D{
  109. private:
  110. basicLogCollection * m_pLog;
  111. protected:
  112. //thresholdNode * m_pThresholds[16]; // 8 - learning 8 - working
  113. basicMutex m_mData;
  114. virtual bool packetHandler( protocolPackage *Package ){ return true; };
  115. public:
  116. protocolInternalLRF3D_SLAVE();
  117. virtual ~protocolInternalLRF3D_SLAVE();
  118. virtual bool create( void );
  119. bool ackShadowSegment( uint32_t dataIdx = 0 );
  120. bool resetChannel(void);
  121. bool pushTarget( targetRecord *ptr );
  122. bool sendTrasholdData( thresholdNode *data, uint32_t dataIdx = 0 );
  123. bool sendMode( uint8_t mode );
  124. bool sendStatus( uint32_t m_nStatus );
  125. bool sendVersion( SOFTWARE_INFO *sv );
  126. };
  127. #else //!PRU_SLAVE
  128. class protocolInternalLRF3D_MASTER: public protocolInternalLRF3D{
  129. private:
  130. basicLogCollection * m_pLog;
  131. protected:
  132. virtual bool packetHandler( protocolPackage *Package ){ return true; };
  133. bool synchTimeStage2();
  134. public:
  135. protocolInternalLRF3D_MASTER();
  136. virtual ~protocolInternalLRF3D_MASTER();
  137. virtual bool create(void);
  138. bool resetChannel(void);
  139. bool ackThresholdSegment( uint32_t dataIdx = 0 );
  140. bool ackShadowSegment( uint32_t dataIdx = 0 );
  141. bool requestThresholdData( uint8_t lrf_id );
  142. bool sendMode( uint8_t Mode );
  143. bool sendSoftwareUpdate( uint8_t *ptr );
  144. bool sendShadowData( uint8_t *ptr );
  145. };
  146. #endif //!PRU_SLAVE
  147. //https://www.exler.ru/blog/kak-vernut-staryy-interfeys-facebook.htm
  148. #endif