fix uart init bug
This commit is contained in:
parent
c5b154eb7d
commit
117d9ec29b
|
@ -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:
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -51,6 +51,13 @@ func uartInit() error {
|
||||||
c := &serial.Config{Name: "/dev/ttyS2", Baud: 1500000, FlowCtrl: serial.HWCONTROL_RTS_CTS}
|
c := &serial.Config{Name: "/dev/ttyS2", Baud: 1500000, FlowCtrl: serial.HWCONTROL_RTS_CTS}
|
||||||
var err error
|
var err error
|
||||||
sPort, err = serial.OpenPort(c)
|
sPort, err = serial.OpenPort(c)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(log.ErrorLog, err)
|
||||||
|
return errors.New("port open error!")
|
||||||
|
} else {
|
||||||
|
flushUart() //flush uart data
|
||||||
|
sPort.Close()
|
||||||
|
sPort, err = serial.OpenPort(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(log.ErrorLog, err)
|
log.Println(log.ErrorLog, err)
|
||||||
return errors.New("port open error!")
|
return errors.New("port open error!")
|
||||||
|
@ -58,6 +65,7 @@ func uartInit() error {
|
||||||
flushUart() //flush uart data
|
flushUart() //flush uart data
|
||||||
go uartReadStart()
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
devpath = "/dev/input/event2"
|
devpath = "/dev/input/event1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var curVol uint8 = 0
|
var curVol uint8 = 0
|
||||||
|
|
Loading…
Reference in New Issue