添加串口打开数据开关,tcp接收数据暂时打印不发送给云端
This commit is contained in:
parent
433d480754
commit
8f2d2bac19
BIN
db/gateway.db
BIN
db/gateway.db
Binary file not shown.
|
@ -25,6 +25,7 @@ type Conf struct {
|
||||||
WEBSOCKETURL []string `json:"websocketurl"`
|
WEBSOCKETURL []string `json:"websocketurl"`
|
||||||
POST_TO_SERVER string `json:"post_to_server"`
|
POST_TO_SERVER string `json:"post_to_server"`
|
||||||
DEBUG bool `json:"debug"`
|
DEBUG bool `json:"debug"`
|
||||||
|
OPENSERIAL bool `json:"openserial"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Gateway_info struct {
|
type Gateway_info struct {
|
||||||
|
|
|
@ -21,25 +21,30 @@ func serial_run() {
|
||||||
port_arr = append(port_arr, ports_arr[i])
|
port_arr = append(port_arr, ports_arr[i])
|
||||||
}
|
}
|
||||||
// 解析串口配置
|
// 解析串口配置
|
||||||
for _, i := range port_arr {
|
if conf.OPENSERIAL{
|
||||||
var PARITY serial.Parity
|
for _, i := range port_arr {
|
||||||
switch conf.SERIALPORTS_LIST[i].PARITY {
|
var PARITY serial.Parity
|
||||||
case "N":
|
switch conf.SERIALPORTS_LIST[i].PARITY {
|
||||||
PARITY = 'N'
|
case "N":
|
||||||
case "E":
|
PARITY = 'N'
|
||||||
PARITY = 'E'
|
case "E":
|
||||||
|
PARITY = 'E'
|
||||||
|
}
|
||||||
|
// 打开串口
|
||||||
|
SERIAL_PORT[i], err = serial.OpenPort(&serial.Config{
|
||||||
|
Name: conf.SERIALPORTS_LIST[i].COM,
|
||||||
|
Baud: conf.SERIALPORTS_LIST[i].BAUDS,
|
||||||
|
Parity: PARITY,
|
||||||
|
ReadTimeout: time.Millisecond * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
|
||||||
|
|
||||||
|
// ReadTimeout: time.Second * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
|
||||||
|
|
||||||
|
})
|
||||||
|
check(err)
|
||||||
|
defer SERIAL_PORT[i].Close()
|
||||||
}
|
}
|
||||||
// 打开串口
|
|
||||||
SERIAL_PORT[i], err = serial.OpenPort(&serial.Config{
|
|
||||||
Name: conf.SERIALPORTS_LIST[i].COM,
|
|
||||||
Baud: conf.SERIALPORTS_LIST[i].BAUDS,
|
|
||||||
Parity: PARITY,
|
|
||||||
ReadTimeout: time.Millisecond * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
|
|
||||||
// ReadTimeout: time.Second * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
|
|
||||||
})
|
|
||||||
check(err)
|
|
||||||
defer SERIAL_PORT[i].Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.DEBUG {
|
if conf.DEBUG {
|
||||||
log.Println(SERIAL_PORT)
|
log.Println(SERIAL_PORT)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue