Skip to content

Commit

Permalink
增加GS雷达OTA功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanyiaini committed Aug 24, 2023
1 parent f161e66 commit 7cd9cc3
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(ydlidar_sdk C CXX)
# version
set(YDLIDAR_SDK_VERSION_MAJOR 1)
set(YDLIDAR_SDK_VERSION_MINOR 1)
set(YDLIDAR_SDK_VERSION_PATCH 17)
set(YDLIDAR_SDK_VERSION_PATCH 18)
set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH})

##########################################################
Expand Down Expand Up @@ -62,7 +62,7 @@ endif()
option( BUILD_SHARED_LIBS "Build shared libraries." OFF)
option( BUILD_EXAMPLES "Build Example." ON)
option( BUILD_CSHARP "Build CSharp." OFF)
option( BUILD_TEST "Build Test." ON)
option( BUILD_TEST "Build Test." OFF)

############################################################################
# find package
Expand Down
17 changes: 15 additions & 2 deletions core/common/DriverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace ydlidar
PropertyBuilderByName(device_info, BaseDevInfo, protected);
//模组设备信息
PropertyBuilderByName(device_info, ModuleDevInfo, protected);
//OTA文件
PropertyBuilderByName(std::string, OtaName, protected);
//OTA文件加密
PropertyBuilderByName(bool, OtaEncode, protected);

/**
* @par Constructor
Expand Down Expand Up @@ -462,13 +466,22 @@ namespace ydlidar
* @param[in] addr 雷达地址
* @return 成功返回RESULT_OK,否则返回非RESULT_OK
*/
virtual result_t setWorkMode(int mode = 0, uint8_t addr = 0x00) { return RESULT_FAIL; }
virtual result_t setWorkMode(int mode = 0, uint8_t addr = 0x00) {
return RESULT_FAIL;
}

/**
* @brief 解析点云数据并判断带不带强度信息(目前只针对三角雷达)
* @return 成功返回RESULT_OK,否则返回非RESULT_OK
*/
virtual result_t getIntensityFlag() { return RESULT_OK; }
virtual result_t getIntensityFlag() {
return RESULT_OK;
}

// 开始OTA升级
virtual bool ota() {
return false;
}

public:
enum YDLIDAR_MODLES
Expand Down
29 changes: 22 additions & 7 deletions core/common/ydlidar_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@
#define GS_LIDAR_CMD_SET_BIAS 0xD9
#define GS_LIDAR_CMD_SET_DEBUG_MODE 0xF0

//模组地址
#define LIDAR_MODULE_1 0x01
#define LIDAR_MODULE_2 0x02
#define LIDAR_MODULE_3 0x04
#define LIDAR_MODULE_ALL 0x00
#define LIDAR_MAXCOUNT 3 //最大模组数

/** @} LIDAR CMD Protocol */

//GS
Expand All @@ -152,13 +159,6 @@

#define SDK_SNLEN 16 //序列号长度

/// CT Package Type
typedef enum {
CT_Normal = 0,///< Normal package
CT_RingStart = 1,///< Starting package
CT_Tail,
} CT;

/// Default Node Quality
#define Node_Default_Quality (10)
/// Starting Node
Expand All @@ -182,6 +182,20 @@ typedef enum {
#define USERVERSIONNDEX 1
#define HEALTHINDEX 3

//超时定义
#define TIMEOUT_100 100
#define TIMEOUT_300 300
#define TIMEOUT_500 500 //500ms
#define TIMEOUT_1S 1000
#define TIMEOUT_2S 2000

/// CT Package Type
typedef enum {
CT_Normal = 0,///< Normal package
CT_RingStart = 1,///< Starting package
CT_Tail,
} CT;

//雷达协议类型
typedef enum {
Protocol_V1 = 0, //V1 version
Expand Down Expand Up @@ -401,6 +415,7 @@ struct gs_package_head {
uint8_t type;
uint16_t size;
} __attribute__((packed));
#define GSPACKEGEHEADSIZE sizeof(gs_package_head)
//GS系列设备信息
struct gs_device_info {
uint8_t hwVersion; //硬件版本号
Expand Down
9 changes: 9 additions & 0 deletions src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,13 @@ bool CYdLidar::getDeviceInfo(std::vector<device_info_ex>& dis)
return false;
}

bool CYdLidar::ota()
{
if (lidarPtr)
return lidarPtr->ota();
return false;
}

/*-------------------------------------------------------------
isRangeValid
-------------------------------------------------------------*/
Expand Down Expand Up @@ -1789,6 +1796,8 @@ bool CYdLidar::checkCOMMs()
lidarPtr->setScanFreq(m_ScanFrequency);
lidarPtr->setSupportMotorDtrCtrl(m_SupportMotorDtrCtrl);
lidarPtr->setBottom(m_Bottom);
lidarPtr->setOtaName(otaName);
lidarPtr->setOtaEncode(otaEncode);

printf("[YDLIDAR] Lidar successfully connected [%s:%d]\n",
m_SerialPort.c_str(), m_SerialBaudrate);
Expand Down
14 changes: 14 additions & 0 deletions src/CYdLidar.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ class YDLIDAR_API CYdLidar {
//获取级联设备信息
bool getDeviceInfo(std::vector<device_info_ex>& dis);

//OTA功能相关
//设置OTA文件路径
void setOtaFile(const std::string& name) {
otaName = name;
}
//设置OTA文件加密
void setOtaEncode(bool e) {
otaEncode = e;
}
//开始OTA升级
bool ota();

private:
/**
* @brief check LiDAR instance and connect to LiDAR,
Expand Down Expand Up @@ -352,6 +364,8 @@ class YDLIDAR_API CYdLidar {

bool m_SunNoise = false; //阳光噪点过滤标识
bool m_GlassNoise = false; //玻璃噪点过滤标识
std::string otaName; //OTA文件路径
bool otaEncode = true; //OTA是否加密
}; // End of class
#endif // CYDLIDAR_H

Expand Down
Loading

0 comments on commit 7cd9cc3

Please sign in to comment.