From 117d9ec29b3a36cd6464a5b5d9571a5955c24fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=9B=BD=E5=BB=BA?= Date: Thu, 27 Sep 2018 12:14:48 +0800 Subject: [PATCH] fix uart init bug --- .../src/netease_control_center/glide.lock | 4 +++- .../modules/hardware/mcu_leds/atservice/atservice.go | 3 ++- .../hardware/mcu_leds/atservice/uartdriver.go | 12 +++++++++++- .../modules/hardware/mcu_leds/main.go | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/netease_control_center_common_module/src/netease_control_center/glide.lock b/app/netease_control_center_common_module/src/netease_control_center/glide.lock index 454ff8e..4aef152 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/glide.lock +++ b/app/netease_control_center_common_module/src/netease_control_center/glide.lock @@ -1,5 +1,5 @@ hash: 68ce7d30bd26f2275d9a8cc38363bb7c5b81d6a4b3405aed1711f1d4fb602414 -updated: 2018-07-03T10:07:34.800484175+08:00 +updated: 2018-09-26T17:14:10.602779665+08:00 imports: - name: github.com/bitly/go-simplejson version: aabad6e819789e569bd6aabf444c935aa9ba1e44 @@ -75,6 +75,8 @@ imports: version: cdffdb33acae0e14efff2628f9bae377b597840e - name: github.com/xxtea/xxtea-go version: 35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242 + subpackages: + - xxtea - name: golang.org/x/crypto version: 0fcca4842a8d74bfddc2c96a073bd2a4d2a7a2e8 subpackages: diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/atservice.go b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/atservice.go index d66c010..99d6a43 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/atservice.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/atservice.go @@ -251,6 +251,7 @@ func removeAllNode(status AT_CMD_RSP) { func respTimeoutcallback() { log.Println(log.WarningLog, "respTimeoutcallback") removeNode(AT_CMD_RSP_WAIT_TIMEOUT, nil) + resetRevData() } func atDataRev(rev []byte) { @@ -308,7 +309,7 @@ func atDataRev(rev []byte) { atCmdRxDataInfo.checkSumCalc += uint16(waitDataSizeChar) atCmdRxDataInfo.dataLen += (uint16(waitDataSizeChar) << 8) atCmdRxDataInfo.rxState = AT_PKG_RX_GET_DATA - //log.Println(atCmdDataInfo.dataLen) + //log.Println(log.WarningLog, atCmdRxDataInfo.dataLen) case AT_PKG_RX_GET_DATA: remainBytes := (int(atCmdRxDataInfo.dataLen) - atCmdRxDataInfo.atDataBuffer.Len()) atCmdRxDataInfo.atDataBuffer.Write(revDataBuffer.Next(remainBytes)) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/uartdriver.go b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/uartdriver.go index cbb4c8a..ef8cf1c 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/uartdriver.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/atservice/uartdriver.go @@ -56,7 +56,15 @@ func uartInit() error { return errors.New("port open error!") } else { flushUart() //flush uart data - go uartReadStart() + sPort.Close() + sPort, err = serial.OpenPort(c) + if err != nil { + log.Println(log.ErrorLog, err) + return errors.New("port open error!") + } else { + flushUart() //flush uart data + go uartReadStart() + } } return err @@ -150,5 +158,7 @@ func flushUart() error { log.Println(log.ErrorLog, err) } + log.Println(log.WarningLog, "flash the uart.................") + return err } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/main.go b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/main.go index 394c765..c02ad2d 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/main.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/hardware/mcu_leds/main.go @@ -11,7 +11,7 @@ import ( ) const ( - devpath = "/dev/input/event2" + devpath = "/dev/input/event1" ) var curVol uint8 = 0