完善配置以及日志
This commit is contained in:
parent
612ed4b281
commit
cb86495fb4
|
@ -123,14 +123,14 @@
|
||||||
],
|
],
|
||||||
"serialports_list": {
|
"serialports_list": {
|
||||||
"loraport": {
|
"loraport": {
|
||||||
"com": "/dev/cu.wchusbserial141420",
|
"com": "/dev/cu.wchusbserial141420",
|
||||||
"bauds": 115200,
|
"bauds": 115200,
|
||||||
"size": 8,
|
"size": 8,
|
||||||
"parity": "E",
|
"parity": "E",
|
||||||
"stopbits": 1,
|
"stopbits": 1,
|
||||||
"readtimeout": 100,
|
"readtimeout": 100,
|
||||||
"note": "lorawan"
|
"note": "lorawan"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rs485devices": {
|
"rs485devices": {
|
||||||
"15394892-E8B0-4FF2-BC35-1BF380BD1B68": {
|
"15394892-E8B0-4FF2-BC35-1BF380BD1B68": {
|
||||||
|
@ -211,5 +211,6 @@
|
||||||
"post_to_server": "https://smartoilets.cn/socketServer/statis/push",
|
"post_to_server": "https://smartoilets.cn/socketServer/statis/push",
|
||||||
"debug": true,
|
"debug": true,
|
||||||
"openserial":false,
|
"openserial":false,
|
||||||
"open_tcp_server":false
|
"open_tcp_server":false,
|
||||||
|
"check_serial":true
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ type Conf struct {
|
||||||
WIRELESSSLAVEDEVICES []WirelessSlaveDevice `json:"wireless_slave_devices"`
|
WIRELESSSLAVEDEVICES []WirelessSlaveDevice `json:"wireless_slave_devices"`
|
||||||
//是否启动tcpserver
|
//是否启动tcpserver
|
||||||
OPENTCPSETVER bool `json:"open_tcp_server"`
|
OPENTCPSETVER bool `json:"open_tcp_server"`
|
||||||
|
CHECKSERIAL bool `json:"check_serial"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//无线 下位机
|
//无线 下位机
|
||||||
|
@ -92,6 +93,24 @@ func init() {
|
||||||
check(err)
|
check(err)
|
||||||
var device Device
|
var device Device
|
||||||
|
|
||||||
|
//var serialPort = make(map[string]int)
|
||||||
|
//for k, i := range conf.SERIALPORTS_LIST {
|
||||||
|
// log.Println(k)
|
||||||
|
// log.Println(i)
|
||||||
|
// if v, c := serialPort[k]; c {
|
||||||
|
// log.Println("repeatd serial port:", v)
|
||||||
|
// os.Exit(3)
|
||||||
|
// } else {
|
||||||
|
// serialPort[k] = 0
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//log.Println("begin print serialPort")
|
||||||
|
//for k, i := range serialPort {
|
||||||
|
// log.Println(k)
|
||||||
|
// log.Println(i)
|
||||||
|
//}
|
||||||
|
|
||||||
log.Println("slaveDevices:", conf.WIRELESSSLAVEDEVICES)
|
log.Println("slaveDevices:", conf.WIRELESSSLAVEDEVICES)
|
||||||
|
|
||||||
// for _,i := range conf.WIRELESSSLAVEDEVICES{
|
// for _,i := range conf.WIRELESSSLAVEDEVICES{
|
||||||
|
@ -101,14 +120,27 @@ func init() {
|
||||||
|
|
||||||
DEVICEDATAS.Lock()
|
DEVICEDATAS.Lock()
|
||||||
DEVICEDATAS.DATA = make(map[string]Device)
|
DEVICEDATAS.DATA = make(map[string]Device)
|
||||||
|
|
||||||
|
//校验是否有设置重复串口
|
||||||
|
//var serialPort = make(map[string]int)
|
||||||
|
|
||||||
//初始化设备,目前conf.DEVICES_LIST
|
//初始化设备,目前conf.DEVICES_LIST
|
||||||
for _, i := range conf.DEVICES_LIST {
|
for _, i := range conf.DEVICES_LIST {
|
||||||
|
|
||||||
|
//if _, c := serialPort[i[1]]; c {
|
||||||
|
// log.Println("repeatd serial port:", i[1])
|
||||||
|
// os.Exit(3)
|
||||||
|
//} else {
|
||||||
|
// serialPort[i[1]] = 0
|
||||||
|
//}
|
||||||
|
|
||||||
device.DATA = make(map[string]interface{})
|
device.DATA = make(map[string]interface{})
|
||||||
device.ID = i[0]
|
device.ID = i[0]
|
||||||
device.VERSION = i[2]
|
device.VERSION = i[2]
|
||||||
//版本号+编号
|
//版本号+编号
|
||||||
DEVICEDATAS.DATA[i[2]+"_"+i[3]] = device
|
DEVICEDATAS.DATA[i[2]+"_"+i[3]] = device
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVICEDATAS.Unlock()
|
DEVICEDATAS.Unlock()
|
||||||
|
|
||||||
demoDevice.ID = "deb03e28-ddcb-4e5d-aa31-d870a1f0f09b"
|
demoDevice.ID = "deb03e28-ddcb-4e5d-aa31-d870a1f0f09b"
|
||||||
|
|
|
@ -11,6 +11,7 @@ func serial_run() {
|
||||||
SERIAL_PORT := make(map[string]*serial.Port)
|
SERIAL_PORT := make(map[string]*serial.Port)
|
||||||
ports_arr := make([]string, 0)
|
ports_arr := make([]string, 0)
|
||||||
port_arr := make([]string, 0)
|
port_arr := make([]string, 0)
|
||||||
|
|
||||||
for _, i := range conf.DEVICES_LIST {
|
for _, i := range conf.DEVICES_LIST {
|
||||||
ports_arr = append(ports_arr, i[1])
|
ports_arr = append(ports_arr, i[1])
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ func serial_run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.DEBUG {
|
if conf.DEBUG {
|
||||||
log.Println(SERIAL_PORT)
|
log.Println("SERIAL_PORT:",SERIAL_PORT)
|
||||||
}
|
}
|
||||||
// 遍历设备对应的串口对应的端口,并放到相应的run_port_device方法
|
// 遍历设备对应的串口对应的端口,并放到相应的run_port_device方法
|
||||||
for j, k := range SERIAL_PORT {
|
for j, k := range SERIAL_PORT {
|
||||||
|
|
Loading…
Reference in New Issue