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/01/07 20:08:08 UTC
[3/4] incubator-mynewt-newt git commit: Ignore write/read requests
echoed back over serial. Only process responses.
Ignore write/read requests echoed back over serial. Only process
responses.
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/90c5fae3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/90c5fae3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/90c5fae3
Branch: refs/heads/master
Commit: 90c5fae3777e425845827382d3c6db6f792c258a
Parents: 7b5a07e
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jan 7 11:06:30 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jan 7 11:06:30 2016 -0800
----------------------------------------------------------------------
newtmgr/newtmgr.go | 3 ++-
newtmgr/protocol/cmdrunner.go | 25 ++++++++++++++-----------
2 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/90c5fae3/newtmgr/newtmgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/newtmgr.go b/newtmgr/newtmgr.go
index e9b5bc1..430aed7 100644
--- a/newtmgr/newtmgr.go
+++ b/newtmgr/newtmgr.go
@@ -17,6 +17,7 @@ package main
import (
"fmt"
+ "io/ioutil"
"log"
"os"
"strings"
@@ -216,7 +217,7 @@ func echoRunCmd(cmd *cobra.Command, args []string) {
nmUsage(cmd, err)
}
- rsp, err := runner.ReadReq()
+ rsp, err := runner.ReadResp()
if err != nil {
nmUsage(cmd, err)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/90c5fae3/newtmgr/protocol/cmdrunner.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/cmdrunner.go b/newtmgr/protocol/cmdrunner.go
index fd4edec..8b04589 100644
--- a/newtmgr/protocol/cmdrunner.go
+++ b/newtmgr/protocol/cmdrunner.go
@@ -25,18 +25,21 @@ type CmdRunner struct {
conn transport.Conn
}
-func (cr *CmdRunner) ReadReq() (*NmgrReq, error) {
- pkt, err := cr.conn.ReadPacket()
- if err != nil {
- return nil, err
+func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
+ for {
+ pkt, err := cr.conn.ReadPacket()
+ if err != nil {
+ return nil, err
+ }
+
+ nmr, err := DeserializeNmgrReq(pkt.GetBytes())
+ if err != nil {
+ return nil, err
+ }
+ if nmr.Op == NMGR_OP_READ_RSP || nmr.Op == NMGR_OP_WRITE_RSP {
+ return nmr, nil
+ }
}
-
- nmr, err := DeserializeNmgrReq(pkt.GetBytes())
- if err != nil {
- return nil, err
- }
-
- return nmr, nil
}
func (cr *CmdRunner) WriteReq(nmr *NmgrReq) error {