-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstart_node.sh
67 lines (61 loc) · 1.88 KB
/
start_node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#Author: David Hu
#Date: 2022-07
# Exit on error
set -e
echo "Instructions:"
echo " [product_type] = LD06/LD19"
echo " [communication_mode] = serial/network"
echo " [serial_port_number] = usb device mount files,example:/dev/ttyUSB0."
echo " [server_ip] = TCP or UDP server host ip, example: 192.168.1.200"
echo " [server_port] = TCP or UDP server host port, example: 2000"
echo "For Example:"
echo " input [product_type]=LD06"
echo " input [communication_mode]=serial"
echo " input [serial_port_number]=/dev/ttyUSB0"
echo " input [server_ip]=<Enter key>"
echo " input [server_port]=<Enter key>"
echo " or "
echo " input [product_type]=LD06"
echo " input [communication_mode]=network"
echo " input [serial_port_number]=<Enter key>"
echo " input [server_ip]=192.168.1.200"
echo " input [server_port]=2000"
read -p "input [product_type]=" PRODUCT_TYPE
read -p "input [communication_mode]=" COMM_MODE
read -p "input [serial_port_number]=" PORT_PATH
read -p "input [server_ip]=" SERVER_IP_ADDR
read -p "input [server_port]=" SERVER_PORT_ADDR
if [ ! ${PRODUCT_TYPE} ]
then
echo "ERROR [product_type] input is null"
exit 0
fi
if [ ! ${COMM_MODE} ]
then
echo "ERROR [communication_mode] input is null"
exit 0
fi
LOG_NAME="test`date +%Y%m%d-%H-%M`.log"
if [ $COMM_MODE == "network" ]
then
echo "start node exec"
if [ ! -e "./log" ];then
mkdir log
echo "create ./log/"
fi
echo "output log to ./log/${LOG_NAME}"
./build/ldlidar_stl_node ${PRODUCT_TYPE} networkcom_tcpclient ${SERVER_IP_ADDR} ${SERVER_PORT_ADDR} > ./log/${LOG_NAME}
elif [ $COMM_MODE == "serial" ]
then
sudo chmod 777 ${PORT_PATH}
echo "start node exec"
if [ ! -e "./log" ];then
mkdir log
echo "create ./log/"
fi
echo "output log to ./log/${LOG_NAME}"
./build/ldlidar_stl_node ${PRODUCT_TYPE} serialcom ${PORT_PATH} > ./log/${LOG_NAME}
else
echo "input [communication_mode] is error."
fi