Skip to content

Commit 4ce6fc7

Browse files
committed
Merge branch 'jenkins'
2 parents 4fab810 + f2fd92c commit 4ce6fc7

26 files changed

Lines changed: 1443 additions & 51 deletions

File tree

.gitmodules

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[submodule "vendor/github.com/creack/goselect"]
2+
path = vendor/github.com/creack/goselect
3+
url = https://github.com/creack/goselect
4+
[submodule "vendor/github.com/jessevdk/go-flags"]
5+
path = vendor/github.com/jessevdk/go-flags
6+
url = https://github.com/jessevdk/go-flags
7+
[submodule "vendor/github.com/joaojeronimo/go-crc16"]
8+
path = vendor/github.com/joaojeronimo/go-crc16
9+
url = https://github.com/joaojeronimo/go-crc16
10+
[submodule "vendor/github.com/proactivity-lab/go-loggers"]
11+
path = vendor/github.com/proactivity-lab/go-loggers
12+
url = https://github.com/proactivity-lab/go-loggers
13+
[submodule "vendor/github.com/proactivity-lab/go-moteconnection"]
14+
path = vendor/github.com/proactivity-lab/go-moteconnection
15+
url = https://github.com/proactivity-lab/go-moteconnection
16+
[submodule "vendor/go.bug.st/serial.v1"]
17+
path = vendor/go.bug.st/serial.v1
18+
url = https://go.bug.st/git/serial.v1.git
19+
[submodule "vendor/golang.org/x/sys"]
20+
path = vendor/golang.org/x/sys
21+
url = https://go.googlesource.com/sys

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
11
# go-devparam
2-
Go library and application for accessing device parameters.
2+
3+
Go library and applications for accessing device parameters using the
4+
deviceparameters protocol: <https://github.com/thinnect/tos-devparam>.
5+
6+
`deviceparameter`
7+
A basic utility for dealing with individual nodes and parameters.
8+
See the [deviceparameter README](cmd/deviceparameter/README.md) for details.
9+
10+
`deviceparameters`
11+
A utility for dealing with several parameters on multiple nodes.
12+
See the [deviceparameters README](cmd/deviceparameters/README.md) for details.
13+
14+
# Dependencies
15+
Go dependencies have been vendored as submodules under the vendor directory.
16+
17+
Building the _deb_ package requires `checkinstall` and `ronn`.
18+
19+
`ronn` can be obtained from <https://github.com/rtomayko/ronn>.
20+
21+
# Building
22+
23+
Check out all submodules, install `ronn` and `checkinstall`.
24+
25+
Enter `cmd/deviceparameter` or `cmd/deviceparameters` and execute `make` or
26+
enter `cmd` and execute the `build-deb.sh` script.
27+
28+
Both applications can be cross-compiled for Windows and for use on ARM based
29+
Linux platforms, though packaging only works on the native architecture. Take a
30+
look at the Makefiles for details.

cmd/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Makefile for building and installing deviceparameter and deviceparameters
2+
MAKEFILE_LOCATION := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
3+
4+
all: deviceparameter deviceparameters
5+
6+
deviceparameter:
7+
cd deviceparameter && make clean && make
8+
9+
deviceparameters:
10+
cd deviceparameters && make clean && make
11+
12+
install: deviceparameter deviceparameters
13+
install -d -m0755 /usr/local/man/man1
14+
install -m0755 $(MAKEFILE_LOCATION)/deviceparameter/deviceparameter /usr/bin
15+
install -m0664 $(MAKEFILE_LOCATION)/deviceparameter/deviceparameter.1.gz /usr/local/man/man1
16+
install -m0755 $(MAKEFILE_LOCATION)/deviceparameters/deviceparameters /usr/bin
17+
install -m0664 $(MAKEFILE_LOCATION)/deviceparameters/deviceparameters.1.gz /usr/local/man/man1
18+
19+
.PHONY: deviceparameter
20+
.PHONY: deviceparameters

cmd/build-deb.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
RELEASE_DATE=$(date -u +'%Y%m%d')
4+
5+
OPTIONS+=" --type=debian"
6+
OPTIONS+=" --default" # answer yes to any questions
7+
OPTIONS+=" --fstrans" # simulate filesystem so root permissions not needed
8+
OPTIONS+=" --install=no" # just make, don't install the package
9+
OPTIONS+=" --nodoc" # as long as actual docs don't exist
10+
11+
OPTIONS+=" --pkgname=mist-device-parameters"
12+
OPTIONS+=" --pkgversion=0.1.0"
13+
OPTIONS+=" --pkgrelease=$RELEASE_DATE"
14+
OPTIONS+=" --provides=mist-device-parameters"
15+
OPTIONS+=" --pkglicense=MIT"
16+
OPTIONS+=" --maintainer=somebody@thinnect.com"
17+
18+
checkinstall $OPTIONS

cmd/description-pak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mist deviceparameter and deviceparameters.

cmd/deviceparameter/Makefile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,45 @@
33
BUILD_DATE = $(shell date -u '+%Y-%m-%d_%H:%M:%S')
44
BUILD_DISTRO = $(shell lsb_release -sd)
55

6-
all: build
6+
all: deviceparameter manual
77

88
win32: export GOOS=windows
99
win32: export GOARCH=386
10-
win32: winbuild
10+
win32: deviceparameter.exe
1111

1212
win64: export GOOS=windows
1313
win64: export GOARCH=amd64
14-
win64: winbuild
14+
win64: deviceparameter.exe
1515

1616
raspberry: export GOOS=linux
1717
raspberry: export GOARCH=arm
1818
raspberry: export GOARM=6
19-
raspberry: build
19+
raspberry: deviceparameter
2020

2121
raspberry2: export GOOS=linux
2222
raspberry2: export GOARCH=arm
2323
raspberry2: export GOARM=7
24-
raspberry2: build
24+
raspberry2: deviceparameter
2525

26-
build:
26+
deviceparameter:
2727
go build -o deviceparameter -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
2828

29-
winbuild:
29+
deviceparameter.exe:
3030
go build -o deviceparameter.exe -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
3131

32-
install:
32+
deviceparameter.1.gz:
33+
ronn --roff README.md
34+
mv README.1 deviceparameter.1
35+
gzip deviceparameter.1
36+
37+
manual: deviceparameter.1.gz
38+
39+
install: deviceparameter manual
3340
install -m 0755 deviceparameter /usr/local/bin
41+
install -m 0644 deviceparameter /usr/local/man/man1
42+
43+
clean:
44+
rm -f deviceparameter
45+
rm -f deviceparameter.1.gz
46+
47+
.PHONY: clean

cmd/deviceparameter/README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
deviceparameter(1) -- get/set individual device parameters, get all parameters.
2+
=============================================
3+
4+
## SYNOPSIS
5+
6+
`deviceparameter` ...<br>
7+
`deviceparameter` `-a` _addr_ `-g` _group_ `-d` _dest_ ...<br>
8+
`deviceparameter` `-p` _parameter_ ...<br>
9+
`deviceparameter` `-p` _parameter_ `-v` _value_ ...<br>
10+
`deviceparameter` `-a` _addr_ `-g` _group_ `-d` _dest_ `-p` _parameter_ ...<br>
11+
`deviceparameter` `-a` _addr_ `-g` _group_ `-d` _dest_ `-p` _parameter_ `-v` _value_ ...<br>
12+
`deviceparameter` `--help`<br>
13+
14+
## DESCRIPTION
15+
16+
**deviceparameter** configures or queries device parameters from Mist nodes
17+
using the deviceparameters protocol: <https://github.com/thinnect/tos-devparam>.
18+
19+
In its default mode, `deviceparameter` will sequentially query all parameters
20+
from the locally connected device. It is possible to query individual parameters
21+
and set their values one by one with the `-p` or `--parameter` option.
22+
23+
It is possible to query and configure remote devices by specifying the source
24+
and destination addresses.
25+
26+
Internally the deviceparameters protocol uses length and a byte array to transmit
27+
values. In order to correctly send an integer value, the type of the integer
28+
needs to be known. A typed value parameter can be specified with `--u8`, `--u16`,
29+
`--u32`, `--u64`, `--i8`, `--i16`, `--i32` or `--i64`. The `-v` or `--value`
30+
option will parse the input as a raw hex string, converting it directly to
31+
binary. ASCII strings can be specified with the `--str` option.
32+
33+
The `--timeout` and `--retries` options change how long a single parameter is
34+
tried before skipping to the next one or giving up.
35+
36+
## OPTIONS
37+
38+
Options control connection parameters:
39+
40+
* `connection`:
41+
This positional argument is used to specify the connection string for the
42+
mist network connection. Use sf@HOST:PORT for a SerialForwarder connection or
43+
serial@PORT:BAUD for a direct serial port.
44+
The default is sf@localhost:9002.
45+
46+
* `-g`, `--group`:
47+
option is used to set the ActiveMessage group. The default is 22,
48+
the value is parsed as a hex string (0x22).
49+
50+
* `-a`, `--address`:
51+
option is used to set the source ActiveMessage address used for remote
52+
requests. The default is 5678, the value is parsed as a hex string (0x5678).
53+
54+
* `-d`, `--destination`:
55+
option is used to set the destination ActiveMessage address and switch over to
56+
a remote request. The value is parsed as a hex string.
57+
58+
Options for controlling task processing timings:
59+
60+
* `--timeout`:
61+
The time spent waiting for a response for a configuration action or query.
62+
Value is in seconds, default is 30.
63+
64+
* `--retries`:
65+
The number of attempts made to configure or query a single parameter during
66+
one operation. The default is 2.
67+
68+
Options for setting the value:
69+
70+
* `-v`, `--value`:
71+
The is parsed as hex strings and converted to binary.
72+
The value must have a length that is divisible by 2 and only contain symbols
73+
[0-9abcdef]. Value is not case sensitive.
74+
* `--str`:
75+
The value is converted to binary using the ASCII encoding.
76+
* `--u8`:
77+
The value is converted to an unsigned 8-bit big-endian integer.
78+
* `--u16`:
79+
The value is converted to an unsigned 16-bit big-endian integer.
80+
* `--u32`:
81+
The value is converted to an unsigned 32-bit big-endian integer.
82+
* `--u64`:
83+
The value is converted to an unsigned 64-bit big-endian integer.
84+
* `--i8`:
85+
The value is converted to a signed 8-bit big-endian integer.
86+
* `--i16`:
87+
The value is converted to a signed 16-bit big-endian integer.
88+
* `--i32`:
89+
The value is converted to a signed 32-bit big-endian integer.
90+
* `--i64`:
91+
The value is converted to a signed 64-bit big-endian integer.
92+
93+
Miscellaneous options:
94+
95+
* `-Q`, `--quiet`:
96+
Turn on quite mode, only parameter values are printed.
97+
98+
* `-D`, `--debug`:
99+
Turn on debug mode, can be specified multiple times to increase verbosity.
100+
101+
* `-V`, `--version`:
102+
Show the application version.
103+
104+
## EXAMPLES
105+
106+
Query all parameters of the locally connected device:
107+
108+
$ deviceparameter
109+
2019/01/28 17:13:36.83 Connected with sf@localhost:9002
110+
2019/01/28 17:13:36.83 Get parameter list:
111+
2019/01/28 17:13:36.84 0: tos_node_id 1234
112+
2019/01/28 17:13:38.86 1: radio_channel 26
113+
...
114+
2019/01/28 17:13:50.052982 21: uptime 18073646
115+
2019/01/28 17:13:50.210797 Done
116+
117+
Set the radio channel on the locally connected device:
118+
119+
$ deviceparameter -p radio_channel --u8 25
120+
2019/01/28 17:16:21.00 Connected with sf@localhost:9002
121+
2019/01/28 17:16:21.00 Set radio_channel to 0x19
122+
2019/01/28 17:16:21.01 radio_channel = 25
123+
2019/01/28 17:16:21.16 Done
124+
125+
Set the name parameter on a remote device:
126+
127+
$ deviceparameter -a 1234 -d 6789 -p name --str FooBar
128+
2019/01/28 17:16:22.01 Connected with sf@localhost:9002
129+
2019/01/28 17:16:22.01 Set name to 0x466F6F426172
130+
2019/01/28 17:16:32.02 name = FooBar
131+
2019/01/28 17:16:32.17 Done
132+
133+
## ENVIRONMENT
134+
135+
**deviceparameter** currently does not take any configuration from the environment.
136+
137+
## BUGS
138+
139+
**deviceparameter** is written in go and an issue tracker is available at
140+
<https://github.com/thinnect/go-devparam/issues>.
141+
142+
## COPYRIGHT
143+
144+
**deviceparameter** is Copyright (C) 2019 Thinnect Inc. <http://www.thinnect.com>
145+
146+
## SEE ALSO
147+
148+
deviceparameters(1)

cmd/deviceparameter/deviceparameter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ type Options struct {
149149
Int32 string `long:"i32" description:"Set value, type is int32"`
150150
Int64 string `long:"i64" description:"Set value, type is int64"`
151151

152-
Debug []bool `short:"D" long:"debug" description:"Debug mode, print raw packets"`
153152
Quiet []bool `short:"Q" long:"quiet" description:"Quiet mode, print only values"`
153+
Debug []bool `short:"D" long:"debug" description:"Debug mode, print raw packets"`
154154
ShowVersion func() `short:"V" long:"version" description:"Show application version"`
155155
}
156156

cmd/deviceparameters/Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Makefile for embedding build info into the executable
2+
3+
BUILD_DATE = $(shell date -u '+%Y-%m-%d_%H:%M:%S')
4+
BUILD_DISTRO = $(shell lsb_release -sd)
5+
6+
all: deviceparameters manual
7+
8+
win32: export GOOS=windows
9+
win32: export GOARCH=386
10+
win32: deviceparameters.exe
11+
12+
win64: export GOOS=windows
13+
win64: export GOARCH=amd64
14+
win64: deviceparameters.exe
15+
16+
raspberry: export GOOS=linux
17+
raspberry: export GOARCH=arm
18+
raspberry: export GOARM=6
19+
raspberry: deviceparameters
20+
21+
raspberry2: export GOOS=linux
22+
raspberry2: export GOARCH=arm
23+
raspberry2: export GOARM=7
24+
raspberry2: deviceparameters
25+
26+
deviceparameters:
27+
go build -o deviceparameters -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
28+
29+
deviceparameters.exe:
30+
go build -o deviceparameters.exe -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
31+
32+
deviceparameters.1.gz:
33+
ronn --roff README.md
34+
mv README.1 deviceparameters.1
35+
gzip deviceparameters.1
36+
37+
manual: deviceparameters.1.gz
38+
39+
install: deviceparameters manual
40+
install -m 0755 deviceparameters /usr/local/bin
41+
install -m 0644 deviceparameters /usr/local/man/man1
42+
43+
clean:
44+
rm -f deviceparameters
45+
rm -f deviceparameters.1.gz
46+
47+
.PHONY: clean

0 commit comments

Comments
 (0)