Skip to content

Commit ee19a3c

Browse files
committed
expand configuration script for setting IP
Conflicts: launch/LMS1xx_configuration.launch src/LMS1xx_configuration.cpp
1 parent 61420b0 commit ee19a3c

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ include_directories(include ${console_bridge_INCLUDE_DIRS})
77
add_library(LMS1xx src/LMS1xx.cpp)
88
target_link_libraries(LMS1xx ${console_bridge_LIBRARIES})
99

10+
1011
# Regular catkin package follows.
1112
find_package(catkin REQUIRED COMPONENTS roscpp sensor_msgs)
12-
catkin_package(CATKIN_DEPENDS roscpp)
13+
catkin_package(
14+
INCLUDE_DIRS include
15+
LIBRARIES LMS1xx
16+
CATKIN_DEPENDS roscpp
17+
)
1318

1419
include_directories(include ${catkin_INCLUDE_DIRS})
20+
1521
add_executable(LMS1xx_node src/LMS1xx_node.cpp)
1622
target_link_libraries(LMS1xx_node LMS1xx ${catkin_LIBRARIES})
1723

include/LMS1xx/LMS1xx.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@
2727
#include <string>
2828
#include <stdint.h>
2929

30+
31+
typedef struct _ipCfg {
32+
33+
/*!
34+
* @brief first octet ip address.
35+
*/
36+
int oct_0;
37+
38+
/*!
39+
* @brief second octet ip address.
40+
*/
41+
int oct_1;
42+
43+
/*!
44+
* @brief third octet ip address.
45+
*/
46+
int oct_2;
47+
48+
/*!
49+
* @brief fourth octet ip address.
50+
*/
51+
int oct_3;
52+
} ipCfg;
53+
3054
/*!
3155
* @class scanCfg
3256
* @brief Structure containing scan configuration.
@@ -241,6 +265,16 @@ class LMS1xx {
241265
bool isConnected();
242266

243267
/*!
268+
* @brief Reboots device.
269+
*/
270+
void reboot();
271+
272+
/*!
273+
* @brief Set IP address.
274+
*/
275+
void setIP(const ipCfg& cfg);
276+
277+
/*!
244278
* @brief Start measurements.
245279
* After receiving this command LMS1xx unit starts spinning laser and measuring.
246280
*/

src/LMS1xx.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@ bool LMS1xx::isConnected() {
7171
return connected;
7272
}
7373

74+
void LMS1xx::reboot() {
75+
char buf[100];
76+
sprintf(buf, "%c%s%c",
77+
0x02, "sMN mSCreboot", 0x03);
78+
79+
write(sockDesc, buf, strlen(buf));
80+
81+
int len = read(sockDesc, buf, 100);
82+
buf[len] = 0;
83+
logWarn("Reboot RX: %s", buf);
84+
}
85+
86+
void LMS1xx::setIP(const ipCfg& cfg) {
87+
char buf[100];
88+
sprintf(buf, "%c%s %X %X %X %X%c",
89+
0x02, "sWN EIIpAddr",
90+
cfg.oct_0, cfg.oct_1, cfg.oct_2, cfg.oct_3,
91+
0x03);
92+
93+
write(sockDesc, buf, strlen(buf));
94+
95+
int len = read(sockDesc, buf, 100);
96+
buf[len] = 0;
97+
logWarn("Set IP RX: %s", buf);
98+
}
99+
74100
void LMS1xx::startMeas() {
75101
char buf[100];
76102
sprintf(buf, "%c%s%c", 0x02, "sMN LMCstartmeas", 0x03);

0 commit comments

Comments
 (0)