Skip to content

Commit babe753

Browse files
committed
support LPX and S2E Serials to get whole ip config from lidar
1 parent eaffbe7 commit babe753

File tree

6 files changed

+53
-6
lines changed

6 files changed

+53
-6
lines changed

app/frame_grabber/IpConfigDlg.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ LRESULT CIpConfigDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lP
4444
{
4545
CenterWindow(GetParent());
4646
this->DoDataExchange();
47+
48+
sl_lidar_ip_conf_t conf;
49+
sl_result ans = LidarMgr::GetInstance().lidar_drv->getLidarIpConf(conf);
50+
51+
if(SL_IS_FAIL(ans)){
52+
MessageBoxA("Failed to get device Ip conf, if you want to get whole Ip conf, please update firmware to the latest");
53+
54+
}
55+
else {
56+
sprintf((char*)ip_, "%u.%u.%u.%u", conf.ip_addr[0], conf.ip_addr[1], conf.ip_addr[2], conf.ip_addr[3]);
57+
sprintf((char*)mask_, "%u.%u.%u.%u", conf.net_mask[0], conf.net_mask[1], conf.net_mask[2], conf.net_mask[3]);
58+
sprintf((char*)gw_, "%u.%u.%u.%u", conf.gw[0], conf.gw[1], conf.gw[2], conf.gw[3]);
59+
}
4760
m_ip.SetWindowTextA(CString(ip_));
4861
m_mask.SetWindowTextA(CString(mask_));
4962
m_gw.SetWindowTextA(CString(gw_));
@@ -88,6 +101,9 @@ LRESULT CIpConfigDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOO
88101
else
89102
is_successful_ = true;
90103

104+
105+
106+
LidarMgr::GetInstance().lidar_drv->reset();
91107
EndDialog(wID);
92108
return 0;
93109
}

sdk/include/rplidar_driver.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,19 @@ class RPlidarDriver {
160160
/// \param timeout The operation timeout value (in millisecond) for the serial port communication.
161161
u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT);
162162

163-
///Set LPX series lidar's static IP address
163+
///Set LPX and S2E series lidar's static IP address
164164
///
165165
/// \param conf Network parameter that LPX series lidar owned
166166
/// \param timeout The operation timeout value (in millisecond) for the ethernet udp communication
167167
u_result setLidarIpConf(const rplidar_ip_conf_t& conf, _u32 timeout = DEFAULT_TIMEOUT);
168168

169-
///Get LPX series lidar's MAC address
169+
///Get LPX and S2E series lidar's static IP address
170+
///
171+
/// \param conf Network parameter that LPX series lidar owned
172+
/// \param timeout The operation timeout value (in millisecond) for the ethernet udp communication
173+
u_result getLidarIpConf(rplidar_ip_conf_t& conf, _u32 timeout = DEFAULT_TIMEOUT);
174+
175+
///Get LPX and S2E series lidar's MAC address
170176
///
171177
/// \param macAddrArray The device MAC information returned from the LPX series lidar
172178
u_result getDeviceMacAddr(_u8* macAddrArray, _u32 timeoutInMs = DEFAULT_TIMEOUT);

sdk/include/sl_lidar_driver.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,19 @@ namespace sl {
338338
/// \param count The number of sample nodes inside the given buffer
339339
virtual sl_result getFrequency(const LidarScanMode& scanMode, const sl_lidar_response_measurement_node_hq_t* nodes, size_t count, float& frequency) = 0;
340340

341-
///Set LPX series lidar's static IP address
341+
///Set LPX and S2E series lidar's static IP address
342342
///
343343
/// \param conf Network parameter that LPX series lidar owned
344344
/// \param timeout The operation timeout value (in millisecond) for the ethernet udp communication
345345
virtual sl_result setLidarIpConf(const sl_lidar_ip_conf_t& conf, sl_u32 timeout = DEFAULT_TIMEOUT) = 0;
346-
347-
///Get LPX series lidar's MAC address
346+
347+
///Get LPX and S2E series lidar's static IP address
348+
///
349+
/// \param conf Network parameter that LPX series lidar owned
350+
/// \param timeout The operation timeout value (in millisecond) for the ethernet udp communication
351+
virtual sl_result getLidarIpConf( sl_lidar_ip_conf_t& conf, sl_u32 timeout = DEFAULT_TIMEOUT) = 0;
352+
//
353+
/////Get LPX series lidar's MAC address
348354
///
349355
/// \param macAddrArray The device MAC information returned from the LPX series lidar
350356
virtual sl_result getDeviceMacAddr(sl_u8* macAddrArray, sl_u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;

sdk/include/sl_lidar_driver_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace sl {
7878
sl_result checkMotorCtrlSupport(MotorCtrlSupport & support, sl_u32 timeout = DEFAULT_TIMEOUT);
7979
sl_result getFrequency(const LidarScanMode& scanMode, const sl_lidar_response_measurement_node_hq_t* nodes, size_t count, float& frequency);
8080
sl_result setLidarIpConf(const sl_lidar_ip_conf_t& conf, sl_u32 timeout);
81+
sl_result getLidarIpConf(sl_lidar_ip_conf_t& conf, sl_u32 timeout);
8182
sl_result getHealth(sl_lidar_response_device_health_t& health, sl_u32 timeout = DEFAULT_TIMEOUT);
8283
sl_result getDeviceMacAddr(sl_u8* macAddrArray, sl_u32 timeoutInMs);
8384
sl_result ascendScanData(sl_lidar_response_measurement_node_t * nodebuffer, size_t count);

sdk/src/rplidar_driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ namespace rp { namespace standalone{ namespace rplidar {
152152
return (_lidarDrv)->setLidarIpConf(conf, timeout);
153153
}
154154

155+
u_result RPlidarDriver::getLidarIpConf(rplidar_ip_conf_t& conf, _u32 timeout)
156+
{
157+
return (_lidarDrv)->getLidarIpConf(conf, timeout);
158+
}
159+
155160
u_result RPlidarDriver::getDeviceMacAddr(_u8* macAddrArray, _u32 timeoutInMs)
156161
{
157162
return (_lidarDrv)->getDeviceMacAddr(macAddrArray, timeoutInMs);

sdk/src/sl_lidar_driver.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,19 @@ namespace sl {
637637
return ans;
638638
}
639639

640+
sl_result getLidarIpConf(sl_lidar_ip_conf_t& conf, sl_u32 timeout)
641+
{
642+
Result<nullptr_t> ans = SL_RESULT_OK;
643+
std::vector<sl_u8> reserve(2);
644+
645+
std::vector<sl_u8> answer;
646+
ans = getLidarConf(SL_LIDAR_CONF_LIDAR_STATIC_IP_ADDR, answer, reserve, timeout);
647+
int len = answer.size();
648+
if (0 == len) return SL_RESULT_INVALID_DATA;
649+
memcpy(&conf, &answer[0], len);
650+
return ans;
651+
}
652+
640653
sl_result getHealth(sl_lidar_response_device_health_t& health, sl_u32 timeout = DEFAULT_TIMEOUT)
641654
{
642655
Result<nullptr_t> ans = SL_RESULT_OK;
@@ -873,7 +886,7 @@ namespace sl {
873886
rp::hal::AutoLocker l(_lock);
874887
ans = _sendCommand(SL_LIDAR_CMD_GET_LIDAR_CONF, &query, sizeof(query));
875888
if (!ans) return ans;
876-
delay(20);
889+
delay(50);
877890
// waiting for confirmation
878891
sl_lidar_ans_header_t response_header;
879892
ans = _waitResponseHeader(&response_header, timeout);

0 commit comments

Comments
 (0)