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/13 20:36:53 UTC
[1/2] incubator-mynewt-newt git commit: Turn off console echo for the
duration of image upload.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/master 06e9bde8c -> f18ce641a
Turn off console echo for the duration of image upload.
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/d96a9755
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/d96a9755
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/d96a9755
Branch: refs/heads/master
Commit: d96a9755486d830adcb76f00c2307ce7a1246c5f
Parents: 06e9bde
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Jan 13 11:20:44 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Jan 13 11:20:44 2016 -0800
----------------------------------------------------------------------
newtmgr/newtmgr.go | 33 +++++++++++++++++++++++++++++++++
newtmgr/protocol/echo.go | 25 ++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d96a9755/newtmgr/newtmgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/newtmgr.go b/newtmgr/newtmgr.go
index 336283a..be51412 100644
--- a/newtmgr/newtmgr.go
+++ b/newtmgr/newtmgr.go
@@ -289,6 +289,30 @@ func imageListCmd(cmd *cobra.Command, args []string) {
}
}
+func echoCtrl(runner *protocol.CmdRunner, on int) error {
+ echo := string(on)
+ echoCtrl, err := protocol.NewEcho()
+ if err != nil {
+ return err
+ }
+ echoCtrl.Message = echo
+
+ nmr, err := echoCtrl.EncodeEchoCtrl()
+ if err != nil {
+ return err
+ }
+
+ if err := runner.WriteReq(nmr); err != nil {
+ return err
+ }
+
+ _, err = runner.ReadResp()
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
func imageUploadCmd(cmd *cobra.Command, args []string) {
if len(args) < 1 {
nmUsage(cmd, util.NewNewtError("Need to specify image to upload"))
@@ -319,6 +343,11 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
nmUsage(cmd, err)
}
+ err = echoCtrl(runner, 0)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
var currOff uint32 = 0
imageSz := uint32(len(imageFile))
@@ -357,6 +386,10 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
currOff = ersp.Offset
fmt.Println(currOff)
}
+ err = echoCtrl(runner, 1)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
fmt.Println("Done")
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d96a9755/newtmgr/protocol/echo.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/echo.go b/newtmgr/protocol/echo.go
index 2d77759..ae7075f 100644
--- a/newtmgr/protocol/echo.go
+++ b/newtmgr/protocol/echo.go
@@ -19,6 +19,11 @@ type Echo struct {
Message string
}
+const (
+ NMGR_ID_ECHO = 0
+ NMGR_ID_CONS_ECHO_CTRL = 1
+)
+
func NewEcho() (*Echo, error) {
s := &Echo{}
return s, nil
@@ -35,7 +40,25 @@ func (e *Echo) EncodeWriteRequest() (*NmgrReq, error) {
nmr.Op = NMGR_OP_WRITE
nmr.Flags = 0
nmr.Group = NMGR_GROUP_ID_DEFAULT
- nmr.Id = 0
+ nmr.Id = NMGR_ID_ECHO
+ nmr.Len = uint16(len(data))
+ nmr.Data = data
+
+ return nmr, nil
+}
+
+func (e *Echo) EncodeEchoCtrl() (*NmgrReq, error) {
+ data := []byte(e.Message)
+
+ nmr, err := NewNmgrReq()
+ if err != nil {
+ return nil, err
+ }
+
+ nmr.Op = NMGR_OP_WRITE
+ nmr.Flags = 0
+ nmr.Group = NMGR_GROUP_ID_DEFAULT
+ nmr.Id = NMGR_ID_CONS_ECHO_CTRL
nmr.Len = uint16(len(data))
nmr.Data = data
[2/2] incubator-mynewt-newt git commit: Use const ids in image
commands.
Posted by ma...@apache.org.
Use const ids in image commands.
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/f18ce641
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f18ce641
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f18ce641
Branch: refs/heads/master
Commit: f18ce641a0faac5f6b7a78c2d834fdaa03a82681
Parents: d96a975
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Jan 13 11:21:28 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Jan 13 11:21:28 2016 -0800
----------------------------------------------------------------------
newtmgr/protocol/imageboot.go | 2 +-
newtmgr/protocol/imagelist.go | 8 +++++++-
newtmgr/protocol/imageupload.go | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f18ce641/newtmgr/protocol/imageboot.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/imageboot.go b/newtmgr/protocol/imageboot.go
index 5bd3fd8..f3e3152 100644
--- a/newtmgr/protocol/imageboot.go
+++ b/newtmgr/protocol/imageboot.go
@@ -48,7 +48,7 @@ func (i *ImageBoot) EncodeWriteRequest() (*NmgrReq, error) {
nmr.Op = NMGR_OP_READ
nmr.Flags = 0
nmr.Group = NMGR_GROUP_ID_IMAGE
- nmr.Id = 2
+ nmr.Id = IMGMGR_NMGR_OP_BOOT
nmr.Len = 0
if i.BootTarget != "" {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f18ce641/newtmgr/protocol/imagelist.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/imagelist.go b/newtmgr/protocol/imagelist.go
index fcc22eb..6598e40 100644
--- a/newtmgr/protocol/imagelist.go
+++ b/newtmgr/protocol/imagelist.go
@@ -24,6 +24,12 @@ type ImageList struct {
Images []string
}
+const (
+ IMGMGR_NMGR_OP_LIST = 0
+ IMGMGR_NMGR_OP_UPLOAD = 1
+ IMGMGR_NMGR_OP_BOOT = 2
+)
+
func NewImageList() (*ImageList, error) {
s := &ImageList{}
s.Images = []string{}
@@ -49,7 +55,7 @@ func (i *ImageList) EncodeWriteRequest() (*NmgrReq, error) {
nmr.Op = NMGR_OP_READ
nmr.Flags = 0
nmr.Group = NMGR_GROUP_ID_IMAGE
- nmr.Id = 0
+ nmr.Id = IMGMGR_NMGR_OP_LIST
nmr.Len = 0
return nmr, nil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f18ce641/newtmgr/protocol/imageupload.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/imageupload.go b/newtmgr/protocol/imageupload.go
index e85bdf2..ee0577d 100644
--- a/newtmgr/protocol/imageupload.go
+++ b/newtmgr/protocol/imageupload.go
@@ -54,7 +54,7 @@ func (i *ImageUpload) EncodeWriteRequest() (*NmgrReq, error) {
nmr.Op = NMGR_OP_WRITE
nmr.Flags = 0
nmr.Group = NMGR_GROUP_ID_IMAGE
- nmr.Id = 1
+ nmr.Id = IMGMGR_NMGR_OP_UPLOAD
nmr.Len = uint16(len(data) + 4)
data, err = i.SerializeImageUploadReq([]byte{})
if err != nil {