You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/05/27 20:34:41 UTC
incubator-mynewt-newt git commit: This closes #10.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop 32e6d1990 -> 3c0d218dc
This closes #10.
Better handle timeouts
Timeouts result in the scanner getting an EOF. A scanner can't be used
after getting an EOF.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/3c0d218d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/3c0d218d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/3c0d218d
Branch: refs/heads/develop
Commit: 3c0d218dc7e68f220683b63382e05bcda506406d
Parents: 32e6d19
Author: spoonofpower <sp...@gmail.com>
Authored: Tue May 24 21:16:49 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri May 27 13:32:12 2016 -0700
----------------------------------------------------------------------
newtmgr/transport/connserial.go | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/3c0d218d/newtmgr/transport/connserial.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go
index 405d7ec..8e230ce 100644
--- a/newtmgr/transport/connserial.go
+++ b/newtmgr/transport/connserial.go
@@ -123,7 +123,14 @@ func (cs *ConnSerial) ReadPacket() (*Packet, error) {
}
}
- return nil, util.NewNewtError("Scanning incoming data failed")
+ err := scanner.Err()
+ if err == nil {
+ // Scanner hit EOF, so we'll need to create a new one. This only
+ // happens on timeouts.
+ err = util.NewNewtError("Timeout reading from serial connection")
+ cs.scanner = bufio.NewScanner(cs.serialChannel)
+ }
+ return nil, err
}
func (cs *ConnSerial) writeData(bytes []byte) {