fix uart init bug

This commit is contained in:
刘国建 2018-09-27 12:14:48 +08:00
parent c5b154eb7d
commit 117d9ec29b
4 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
hash: 68ce7d30bd26f2275d9a8cc38363bb7c5b81d6a4b3405aed1711f1d4fb602414 hash: 68ce7d30bd26f2275d9a8cc38363bb7c5b81d6a4b3405aed1711f1d4fb602414
updated: 2018-07-03T10:07:34.800484175+08:00 updated: 2018-09-26T17:14:10.602779665+08:00
imports: imports:
- name: github.com/bitly/go-simplejson - name: github.com/bitly/go-simplejson
version: aabad6e819789e569bd6aabf444c935aa9ba1e44 version: aabad6e819789e569bd6aabf444c935aa9ba1e44
@ -75,6 +75,8 @@ imports:
version: cdffdb33acae0e14efff2628f9bae377b597840e version: cdffdb33acae0e14efff2628f9bae377b597840e
- name: github.com/xxtea/xxtea-go - name: github.com/xxtea/xxtea-go
version: 35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242 version: 35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
subpackages:
- xxtea
- name: golang.org/x/crypto - name: golang.org/x/crypto
version: 0fcca4842a8d74bfddc2c96a073bd2a4d2a7a2e8 version: 0fcca4842a8d74bfddc2c96a073bd2a4d2a7a2e8
subpackages: subpackages:

View File

@ -251,6 +251,7 @@ func removeAllNode(status AT_CMD_RSP) {
func respTimeoutcallback() { func respTimeoutcallback() {
log.Println(log.WarningLog, "respTimeoutcallback") log.Println(log.WarningLog, "respTimeoutcallback")
removeNode(AT_CMD_RSP_WAIT_TIMEOUT, nil) removeNode(AT_CMD_RSP_WAIT_TIMEOUT, nil)
resetRevData()
} }
func atDataRev(rev []byte) { func atDataRev(rev []byte) {
@ -308,7 +309,7 @@ func atDataRev(rev []byte) {
atCmdRxDataInfo.checkSumCalc += uint16(waitDataSizeChar) atCmdRxDataInfo.checkSumCalc += uint16(waitDataSizeChar)
atCmdRxDataInfo.dataLen += (uint16(waitDataSizeChar) << 8) atCmdRxDataInfo.dataLen += (uint16(waitDataSizeChar) << 8)
atCmdRxDataInfo.rxState = AT_PKG_RX_GET_DATA atCmdRxDataInfo.rxState = AT_PKG_RX_GET_DATA
//log.Println(atCmdDataInfo.dataLen) //log.Println(log.WarningLog, atCmdRxDataInfo.dataLen)
case AT_PKG_RX_GET_DATA: case AT_PKG_RX_GET_DATA:
remainBytes := (int(atCmdRxDataInfo.dataLen) - atCmdRxDataInfo.atDataBuffer.Len()) remainBytes := (int(atCmdRxDataInfo.dataLen) - atCmdRxDataInfo.atDataBuffer.Len())
atCmdRxDataInfo.atDataBuffer.Write(revDataBuffer.Next(remainBytes)) atCmdRxDataInfo.atDataBuffer.Write(revDataBuffer.Next(remainBytes))

View File

@ -56,7 +56,15 @@ func uartInit() error {
return errors.New("port open error!") return errors.New("port open error!")
} else { } else {
flushUart() //flush uart data 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 return err
@ -150,5 +158,7 @@ func flushUart() error {
log.Println(log.ErrorLog, err) log.Println(log.ErrorLog, err)
} }
log.Println(log.WarningLog, "flash the uart.................")
return err return err
} }

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
devpath = "/dev/input/event2" devpath = "/dev/input/event1"
) )
var curVol uint8 = 0 var curVol uint8 = 0