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.

96 lines
3.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __LRF_SCANNER_4TECHNION_HEADER__
  2. #define __LRF_SCANNER_4TECHNION_HEADER__
  3. #include "../../../components/base/basicSettingsProvider.h"
  4. #include "../../../components/base/basicDualThread.h"
  5. #include "../../../components/base/basicMutex.h"
  6. #include "../../../pathfinder/pathfinderDBConnector.h"
  7. #include "../../../components/object/objectPathfinderBinaryLog.h"
  8. //#include "../../../data/protocol/protocol.h"
  9. //#include "../../uart/serialPort.h"
  10. #include <stdio.h> // standard input / output functions
  11. #include <stdlib.h>
  12. #include <string.h> // string function definitions
  13. #include <fcntl.h> // File control definitions
  14. #include <errno.h> // Error number definitions
  15. #include <unistd.h> // UNIX standard function definitions
  16. #include <termios.h> // POSIX terminal control definitions
  17. //#define DEBUG_LRF_DATA
  18. typedef enum E_LRFT_CMD{
  19. CMD_GET_MODE = 0x00,
  20. CMD_GET_PARAM = 0x01,
  21. CMD_SET_PARAM = 0x02,
  22. CMD_START = 0x03,
  23. CMD_STOP = 0x04,
  24. CMD_RESET = 0x05,
  25. CMD_RAW_DATA = 0x06
  26. } LRFT_CMD;
  27. #define CMD_IDX 3
  28. #define LRF_WM_INIT 0
  29. #define LRF_WM_COMMAND 1
  30. #define LRF_WM_DATA 2
  31. #define LRF_WM_STOPING 3
  32. class LRF_techScanner: public basicDualThread {
  33. private:
  34. basicLogCollection * m_pLog;
  35. config_setting_t * m_pSettings;
  36. uint8_t m_bSpeedSPS;
  37. uint16_t m_nPulseCount;
  38. uint16_t m_nByteCount;
  39. uint8_t inBuffer[2][6700];
  40. uint8_t m_bActiveBuffer;
  41. //uint8_t m_bUpdateBuffer;
  42. bool cDATA;
  43. LRF_EVTREC m_sEvent;
  44. // serialPort * m_pPort;
  45. uint8_t m_bWMODE;
  46. PATHFINDER_DBC * m_pDBC;
  47. objectPathfinderBinaryLog * m_pBLOG;
  48. bool m_bDataReady;
  49. basicMutex m_oMutex;
  50. struct termios m_sTTY;
  51. int m_iInFID;
  52. int m_iOutFID;
  53. uint16_t m_pScanData[3329];
  54. PF_TIMESTAMP m_sScanSTS;
  55. PF_TIMESTAMP m_sScanFTS;
  56. uint16_t m_nSampleID;
  57. bool setParams();
  58. bool reqParams();
  59. bool reqMode();
  60. char m_sDevicePath[512];
  61. int m_iLineSpeed;
  62. bool m_bInitComplete;
  63. bool HW_init( CSTR DevicePath, int Speed );
  64. int sendBlock( unsigned char *Data, int DataSize );
  65. int recptBlock( unsigned char *Buffer, int BufferLength );
  66. pthread_t m_sUpdateThreadHandler;
  67. static void * m_fUpdateShutNForget(void *);
  68. protected:
  69. virtual void m_fThreadAProc( void );
  70. virtual void m_fThreadBProc( void );
  71. // virtual int packetChecker(U8 *Buffer, size_t BufferSize);
  72. // virtual protocolPackage * packetExtractor(U8 *Buffer, size_t BufferSize);
  73. // virtual bool packetHandler( protocolPackage *Package );
  74. // virtual void dataEraser(U8*& tPtr);
  75. public:
  76. explicit LRF_techScanner( config_setting_t * Settings = NULL, PATHFINDER_DBC * DBC = NULL );
  77. virtual ~LRF_techScanner();
  78. virtual bool create();
  79. bool setDeviceSPS( uint8_t S );
  80. bool startScan();
  81. bool stopScan();
  82. bool resetDevice();
  83. bool isDead();
  84. };
  85. #endif