From fecd8ff508b33715cbe24ca892fc19a2d1ad1ef5 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 06 十一月 2023 16:34:05 +0800 Subject: [PATCH] 加锁解决同时读串口时报的资源不可用和超时报错 --- main.go | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index b1a14d7..2247522 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ "apsClient/router" "apsClient/serf" "apsClient/service" - "apsClient/service/plc_address" "fmt" "log" "net/http" @@ -29,7 +28,7 @@ } //鍔犺浇plc鍐欏叆鍦板潃 - plc_address.LoadAddressFromFile() + //plc_address.LoadAddressFromFile() // 鍚姩鏁版嵁鍚屾 var serfStartChan = make(chan bool) @@ -43,6 +42,8 @@ "task_status_sync", "device", "device_plc", + "system_status", + "process_model_plc_address", } agent := serf.InitAgent("apsClient", syncTables, sqlitex.GetDB()) @@ -54,10 +55,11 @@ return } - //浠庢枃浠堕噷璇诲彇褰撳墠鐢熶骇璁惧id - conf.Conf.CurrentDeviceID = service.ReadDeviceIDFromFile() - if conf.Conf.CurrentDeviceID == "" { - conf.Conf.CurrentDeviceID = conf.Conf.System.DeviceId + //浠庢枃浠堕噷璇诲彇褰撳墠鐢熶骇璁惧id鑾峰彇璁惧鍒楄〃绗竴涓� + err := service.InitCurrentDeviceID() + if err != nil { + logx.Errorf("InitCurrentDeviceID error: %v, exit", err) + return } // 鍒ゆ柇褰撳墠闆嗙兢鐘舵�� -- Gitblit v1.8.0