I reported this bug months ago. Seems the newtmgr does not check for required arguments/length. The stat command requires arguments, but newtmgr does not check that arguments are present, and then 'index out of range' exception.
dg > On Sep 25, 2016, at 5:11 PM, Kevin Townsend <[email protected]> wrote: > > Should the `stat` command in newtmgr be behaving similarly to the console > command where it returns a list of all stat entries available? > > That was the behaviour I was expecting, though I also tried `stat list`, > `stat show` and `stat all` or just `stat` before looking at the documentation > (which didn't elaborate, but not biggie there are more important problems to > solve!). > > It seems there might be an error here: > > $ newtmgr -c serial1 stat > panic: runtime error: index out of range > > goroutine 1 [running]: > panic(0x42965a0, 0xc820010080) > /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6 > mynewt.apache.org/newt/newtmgr/cli.statsRunCmd(0xc8200df800, > 0xc82000e820, 0x0, 0x2) > /Users/ktown/prog/go/src/mynewt.apache.org/newt/newtmgr/cli/stats.go:57 > +0x946 > github.com/spf13/cobra.(*Command).execute(0xc8200df800, > 0xc82000e620, 0x2, 0x2, 0x0, 0x0) > /Users/ktown/prog/go/src/github.com/spf13/cobra/command.go:565 +0x85a > github.com/spf13/cobra.(*Command).ExecuteC(0xc8200de000, > 0xc8200df800, 0x0, 0x0) > /Users/ktown/prog/go/src/github.com/spf13/cobra/command.go:651 +0x55c > github.com/spf13/cobra.(*Command).Execute(0xc8200de000, 0x0, 0x0) > /Users/ktown/prog/go/src/github.com/spf13/cobra/command.go:610 +0x2d > main.main() > /Users/ktown/prog/go/src/mynewt.apache.org/newt/newtmgr/newtmgr.go:25 > +0x25 > > When I run with a valid name things are fine: > > $ newtmgr -c serial1 stat ble_svc_dis > Return Code = 0 > Stats Name: ble_svc_dis > manufacturer_reads_stat: 0 > model_reads_stat: 0 > serial_reads_stat: 0 > firmware_rev_reads_stat: 0 > hardware_rev_reads_stat: 0 > software_rev_reads_stat: 0 > > It seems there isn't currently a way to know via newtmgr how many stat > entries are present, although this information is available in the console > version. > > I'm running the latest newtmgr available in the master branch of the repo. > > K. > > PS: The stats module is great, BTW. The reason I enjoy using Mynewt so much > is the (sadly uncommon) focus on real product deployments. Details like this > make life so much easier when devices are out in the wild, but those > 'details' tend to be forgotten in a lot of tools and platforms or a sad > afterthought. So many RTOSes and platforms are overly academic and it's > refreshing that the design decisions with Mynewt are being informed by the > realities of real world product releases, and having to debug things in the > field. > -- David G. Simmons (919) 534-5099 Web <https://davidgs.com/> • Blog <https://davidgs.com/davidgs_blog> • Linkedin <http://linkedin.com/in/davidgsimmons> • Twitter <http://twitter.com/TechEvangelist1> • GitHub <http://github.com/davidgs> /** Message digitally signed for security and authenticity. * If you cannot read the PGP.sig attachment, please go to * http://www.gnupg.com/ <http://www.gnupg.com/> Secure your email!!! * Public key available at keyserver.pgp.com <http://keyserver.pgp.com/> **/ ♺ This email uses 100% recycled electrons. Don't blow it by printing! There are only 2 hard things in computer science: Cache invalidation, naming things, and off-by-one errors.
