Upgrade dependencies

This commit is contained in:
Cyrille Nofficial 2020-03-01 18:48:48 +01:00
parent 66def649cb
commit 738c2f5a82
16 changed files with 712 additions and 304 deletions

6
go.mod
View File

@ -3,10 +3,10 @@ module github.com/cyrilix/robocar-led
go 1.13
require (
github.com/cyrilix/robocar-base v0.0.0-20200101163959-0a3e47f0016b
github.com/cyrilix/robocar-protobuf/go v0.0.0-20200101000356-accf7184079a
github.com/cyrilix/robocar-base v0.1.0
github.com/cyrilix/robocar-protobuf/go v1.0.0
github.com/eclipse/paho.mqtt.golang v1.2.0
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.3.4
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/sirupsen/logrus v1.4.2
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect

40
go.sum
View File

@ -5,10 +5,11 @@ github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXn
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/cyrilix/robocar-base v0.0.0-20200101163959-0a3e47f0016b h1:kDor8xsF7goCk+PVqbgTmJXCSEfzO8BjACmUuPkxsYU=
github.com/cyrilix/robocar-base v0.0.0-20200101163959-0a3e47f0016b/go.mod h1:jRQ+lJAHKkdcjwS5vt2t5LX2zM+bxX+gKffixkc2lbA=
github.com/cyrilix/robocar-protobuf/go v0.0.0-20200101000356-accf7184079a h1:IkvehlOZuaxE6T62Kdr1iYjMmcllUOPi/ZQhMhzp844=
github.com/cyrilix/robocar-protobuf/go v0.0.0-20200101000356-accf7184079a/go.mod h1:I+i6Ujns+4DmRmmUej56MItlmT4K2zlMZ35vZrHEfQ4=
github.com/cyrilix/robocar-base v0.1.0 h1:WCx16VxGd7iTS2WdDHdY7p9k5inviZF96vgkEQruql8=
github.com/cyrilix/robocar-base v0.1.0/go.mod h1:U6tjaylQtSC5C1NzeZnfKhc2v7mF7BSuCgdJ7/nJ3IA=
github.com/cyrilix/robocar-protobuf/go v1.0.0 h1:kPsmmYakcIWd/Y73YDufbdILJUna0tJcteKKWlNfVFY=
github.com/cyrilix/robocar-protobuf/go v1.0.0/go.mod h1:I+i6Ujns+4DmRmmUej56MItlmT4K2zlMZ35vZrHEfQ4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.7.3-0.20190506211059-b20a14b54661/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
@ -16,17 +17,25 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
@ -34,6 +43,10 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -42,30 +55,34 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/testcontainers/testcontainers-go v0.0.9/go.mod h1:0Qe9qqjNZgxHzzdHPWwmQ2D49FFO7920hLdJ4yUJXJI=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/testcontainers/testcontainers-go v0.3.0/go.mod h1:br7bkzIukhPSIjy07Ma3OuXjjFvl2jm7CDU0LQNsqLw=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -78,8 +95,11 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools v0.0.0-20181223230014-1083505acf35/go.mod h1:R//lfYlUuTOTfblYI3lGoAAAebUdzjvbmQsuB7Ykd90=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
periph.io/x/periph v3.6.2+incompatible/go.mod h1:EWr+FCIU2dBWz5/wSWeiIUJTriYv9v2j2ENBmgYyy7Y=

View File

@ -1,7 +1,7 @@
package led
import (
"log"
log "github.com/sirupsen/logrus"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/host"
"periph.io/x/periph/host/bcm283x"
@ -111,7 +111,7 @@ func (l *PiColorLed) blink(freq float64) {
green = tmpG
blue = tmpB
}
log.Infof("factor: %v", factor)
l.SetRed(red * factor)
l.SetGreen(green * factor)
l.SetBlue(blue * factor)
@ -133,7 +133,7 @@ var setLed = func(v int, led gpio.PinIO, mutex *sync.Mutex) {
}
err := led.Out(lvl)
if err != nil {
log.Printf("unable to sed pin to %v: %v", lvl, err)
log.Errorf("unable to sed pin to %v: %v", lvl, err)
}
}

View File

@ -1,10 +1,10 @@
package part
import (
"github.com/cyrilix/robocar-base/mqttdevice"
"github.com/cyrilix/robocar-base/testtools"
"github.com/cyrilix/robocar-protobuf/go/events"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/golang/protobuf/proto"
"testing"
"time"
)
@ -50,25 +50,22 @@ func TestLedPart_OnDriveMode(t *testing.T) {
for _, c := range cases {
p.onDriveMode(nil, c.msg)
time.Sleep(1 * time.Millisecond)
var msg events.DriveModeMessage
err := proto.Unmarshal(c.msg.Payload(), &msg)
if err != nil {
t.Errorf("unable to unmarshal drive mode message: %v", err)
}
value := msg.DriveMode
if led.red != c.red {
payload := mqttdevice.NewMqttValue(c.msg.Payload())
value, err := payload.IntValue()
if err != nil {
t.Errorf("payload isn't a led value: %v", err)
}
t.Errorf("driveMode(%v)=invalid value for red channel: %v, wants %v", value, led.red, c.red)
}
if led.green != c.green {
payload := mqttdevice.NewMqttValue(c.msg.Payload())
value, err := payload.IntValue()
if err != nil {
t.Errorf("payload isn't a led value: %v", err)
}
t.Errorf("driveMode(%v)=invalid value for green channel: %v, wants %v", value, led.green, c.green)
}
if led.blue != c.blue {
payload := mqttdevice.NewMqttValue(c.msg.Payload())
value, err := payload.IntValue()
if err != nil {
t.Errorf("payload isn't a led value: %v", err)
}
@ -94,11 +91,13 @@ func TestLedPart_OnRecord(t *testing.T) {
for _, c := range cases {
p.onRecord(nil, c.msg)
if led.blink != c.blink {
payload := mqttdevice.NewMqttValue(c.msg.Payload())
value, err := payload.BoolValue()
var msg events.SwitchRecordMessage
err := proto.Unmarshal(c.msg.Payload(), &msg)
if err != nil {
t.Errorf("payload isn't a bool value: %v", err)
t.Errorf("unable to unmarshal %T message: %v", msg, err)
}
value := msg.Enabled
t.Errorf("onRecord(%v): %v, wants %v", value, c.record, led.blink)
}
}

View File

@ -2,7 +2,7 @@ package cli
import (
"flag"
"github.com/cyrilix/robocar-base/mqttdevice"
"fmt"
"github.com/cyrilix/robocar-base/service"
MQTT "github.com/eclipse/paho.mqtt.golang"
"log"
@ -61,16 +61,20 @@ func HandleExit(p service.Part) {
}()
}
func InitMqttFlags(defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) {
func InitMqttFlagSet(flagSet *flag.FlagSet, defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) {
SetDefaultValueFromEnv(clientId, "MQTT_CLIENT_ID", defaultClientId)
SetDefaultValueFromEnv(mqttBroker, "MQTT_BROKER", "tcp://127.0.0.1:1883")
flag.StringVar(mqttBroker, "mqtt-broker", *mqttBroker, "Broker Uri, use MQTT_BROKER env if arg not set")
flag.StringVar(username, "mqtt-username", os.Getenv("MQTT_USERNAME"), "Broker Username, use MQTT_USERNAME env if arg not set")
flag.StringVar(password, "mqtt-password", os.Getenv("MQTT_PASSWORD"), "Broker Password, MQTT_PASSWORD env if args not set")
flag.StringVar(clientId, "mqtt-client-id", *clientId, "Mqtt client id, use MQTT_CLIENT_ID env if args not set")
flag.IntVar(mqttQos, "mqtt-qos", *mqttQos, "Qos to pusblish message, use MQTT_QOS env if arg not set")
flag.BoolVar(mqttRetain, "mqtt-retain", *mqttRetain, "Retain mqtt message, if not set, true if MQTT_RETAIN env variable is set")
flagSet.StringVar(mqttBroker, "mqtt-broker", *mqttBroker, "Broker Uri, use MQTT_BROKER env if arg not set")
flagSet.StringVar(username, "mqtt-username", os.Getenv("MQTT_USERNAME"), "Broker Username, use MQTT_USERNAME env if arg not set")
flagSet.StringVar(password, "mqtt-password", os.Getenv("MQTT_PASSWORD"), "Broker Password, MQTT_PASSWORD env if args not set")
flagSet.StringVar(clientId, "mqtt-client-id", *clientId, "Mqtt client id, use MQTT_CLIENT_ID env if args not set")
flagSet.IntVar(mqttQos, "mqtt-qos", *mqttQos, "Qos to pusblish message, use MQTT_QOS env if arg not set")
flagSet.BoolVar(mqttRetain, "mqtt-retain", *mqttRetain, "Retain mqtt message, if not set, true if MQTT_RETAIN env variable is set")
}
func InitMqttFlags(defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) {
InitMqttFlagSet(flag.CommandLine, defaultClientId, mqttBroker, username, password, clientId, mqttQos, mqttRetain)
}
func InitIntFlag(key string, defValue int) int {
@ -92,5 +96,24 @@ func InitFloat64Flag(key string, defValue float64) float64 {
}
func Connect(uri, username, password, clientId string) (MQTT.Client, error) {
return mqttdevice.Connect(uri, username, password, clientId)
//create a ClientOptions struct setting the broker address, clientid, turn
//off trace output and set the default message handler
opts := MQTT.NewClientOptions().AddBroker(uri)
opts.SetUsername(username)
opts.SetPassword(password)
opts.SetClientID(clientId)
opts.SetAutoReconnect(true)
opts.SetDefaultPublishHandler(
//define a function for the default message handler
func(client MQTT.Client, msg MQTT.Message) {
fmt.Printf("TOPIC: %s\n", msg.Topic())
fmt.Printf("MSG: %s\n", msg.Payload())
})
//create and start a client using the above ClientOptions
client := MQTT.NewClient(opts)
if token := client.Connect(); token.Wait() && token.Error() != nil {
return nil, fmt.Errorf("unable to connect to mqtt bus: %v", token.Error())
}
return client, nil
}

View File

@ -1,141 +0,0 @@
package mqttdevice
import (
"encoding/json"
"fmt"
"github.com/cyrilix/robocar-base/types"
MQTT "github.com/eclipse/paho.mqtt.golang"
"log"
"strconv"
)
type Publisher interface {
Publish(topic string, payload MqttValue)
}
type Subscriber interface {
Subscribe(topic string, mh MQTT.MessageHandler)
}
type MQTTPubSub interface {
Publisher
Subscriber
}
type pahoMqttPubSub struct {
client MQTT.Client
qos int
retain bool
}
func NewPahoMqttPubSub(client MQTT.Client, qos int, retain bool) MQTTPubSub {
p := pahoMqttPubSub{client: client, qos: qos, retain: retain}
return &p
}
func Connect(uri, username, password, clientId string) (MQTT.Client, error) {
//create a ClientOptions struct setting the broker address, clientid, turn
//off trace output and set the default message handler
opts := MQTT.NewClientOptions().AddBroker(uri)
opts.SetUsername(username)
opts.SetPassword(password)
opts.SetClientID(clientId)
opts.SetAutoReconnect(true)
opts.SetDefaultPublishHandler(
//define a function for the default message handler
func(client MQTT.Client, msg MQTT.Message) {
fmt.Printf("TOPIC: %s\n", msg.Topic())
fmt.Printf("MSG: %s\n", msg.Payload())
})
//create and start a client using the above ClientOptions
client := MQTT.NewClient(opts)
if token := client.Connect(); token.Wait() && token.Error() != nil {
return nil, fmt.Errorf("unable to connect to mqtt bus: %v", token.Error())
}
return client, nil
}
// Publish message to broker
func (p *pahoMqttPubSub) Publish(topic string, payload MqttValue) {
tokenResp := p.client.Publish(topic, byte(p.qos), p.retain, string(payload))
if tokenResp.Error() != nil {
log.Fatalf("%+v\n", tokenResp.Error())
}
}
// Register func to execute on message
func (p *pahoMqttPubSub) Subscribe(topic string, callback MQTT.MessageHandler) {
tokenResp := p.client.Subscribe(topic, byte(p.qos), callback)
if tokenResp.Error() != nil {
log.Fatalf("%+v\n", tokenResp.Error())
}
}
type MqttValue []byte
func NewMqttValue(v interface{}) MqttValue {
switch val := v.(type) {
case string:
return MqttValue(val)
case float32, float64:
return MqttValue(fmt.Sprintf("%0.2f", val))
case int, int8, int16, int32, int64:
return MqttValue(fmt.Sprintf("%d", val))
case bool:
if val {
return []byte("ON")
} else {
return []byte("OFF")
}
case []byte:
return val
case MqttValue:
return val
default:
jsonValue, err := json.Marshal(v)
if err != nil {
log.Printf("unable to mashall to json value '%v': %v", v, err)
return nil
}
return jsonValue
}
}
func (m *MqttValue) IntValue() (int, error) {
return strconv.Atoi(string(*m))
}
func (m *MqttValue) Float32Value() (float32, error) {
val := string(*m)
r, err := strconv.ParseFloat(val, 32)
return float32(r), err
}
func (m *MqttValue) Float64Value() (float64, error) {
val := string(*m)
return strconv.ParseFloat(val, 64)
}
func (m *MqttValue) StringValue() (string, error) {
return string(*m), nil
}
func (m *MqttValue) DriveModeValue() (types.DriveMode, error) {
val, err := m.IntValue()
if err != nil {
return types.DriveModeInvalid, err
}
return types.DriveMode(val), nil
}
func (m *MqttValue) ByteSliceValue() ([]byte, error) {
return *m, nil
}
func (m *MqttValue) BoolValue() (bool, error) {
val := string(*m)
switch val {
case "ON":
return true, nil
case "OFF":
return false, nil
default:
return false, fmt.Errorf("value %v can't be converted to bool", val)
}
}

View File

@ -1,35 +1,11 @@
package testtools
import (
"github.com/cyrilix/robocar-base/mqttdevice"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/golang/protobuf/proto"
log "github.com/sirupsen/logrus"
"sync"
)
func NewFakePublisher() *FakePublisher {
return &FakePublisher{msg: make(map[string]mqttdevice.MqttValue)}
}
type FakePublisher struct {
muMsg sync.Mutex
msg map[string]mqttdevice.MqttValue
}
func (f *FakePublisher) Publish(topic string, payload mqttdevice.MqttValue) {
f.muMsg.Lock()
defer f.muMsg.Unlock()
f.msg[topic] = payload
}
func (f *FakePublisher) PublishedEvent(topic string) mqttdevice.MqttValue {
f.muMsg.Lock()
defer f.muMsg.Unlock()
return f.msg[topic]
}
type fakeMessage struct {
qos byte
topic string

View File

@ -1,36 +0,0 @@
package types
import (
"log"
)
type DriveMode int
const (
DriveModeInvalid = -1
DriveModeUser = iota
DriveModePilot
)
func ToString(mode DriveMode) string {
switch mode {
case DriveModeUser:
return "user"
case DriveModePilot:
return "pilot"
default:
return ""
}
}
func ParseString(val string) DriveMode {
switch val {
case "user":
return DriveModeUser
case "pilot":
return DriveModePilot
default:
log.Printf("invalid DriveMode: %v", val)
return DriveModeInvalid
}
}

View File

@ -1,10 +0,0 @@
package types
/* Radio control value */
type RCValue struct {
Value float64
Confidence float64
}
type Steering RCValue
type Throttle RCValue

View File

@ -1,5 +0,0 @@
package types
type BoundingBox struct {
Left, Top, Right, Bottom int
}

View File

@ -6,6 +6,7 @@ package events
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
math "math"
)
@ -80,11 +81,12 @@ func (TypeObject) EnumDescriptor() ([]byte, []int) {
}
type FrameRef struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
CreatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FrameRef) Reset() { *m = FrameRef{} }
@ -126,6 +128,13 @@ func (m *FrameRef) GetId() string {
return ""
}
func (m *FrameRef) GetCreatedAt() *timestamp.Timestamp {
if m != nil {
return m.CreatedAt
}
return nil
}
type FrameMessage struct {
Id *FrameRef `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Frame []byte `protobuf:"bytes,2,opt,name=frame,proto3" json:"frame,omitempty"`
@ -369,10 +378,11 @@ func (m *ObjectsMessage) GetFrameRef() *FrameRef {
return nil
}
// BoundingBox that contains an object
type Object struct {
Type TypeObject `protobuf:"varint,1,opt,name=type,proto3,enum=robocar.events.TypeObject" json:"type,omitempty"`
LLeft int32 `protobuf:"varint,2,opt,name=lLeft,proto3" json:"lLeft,omitempty"`
Up int32 `protobuf:"varint,3,opt,name=up,proto3" json:"up,omitempty"`
Left int32 `protobuf:"varint,2,opt,name=left,proto3" json:"left,omitempty"`
Top int32 `protobuf:"varint,3,opt,name=top,proto3" json:"top,omitempty"`
Right int32 `protobuf:"varint,4,opt,name=right,proto3" json:"right,omitempty"`
Bottom int32 `protobuf:"varint,5,opt,name=bottom,proto3" json:"bottom,omitempty"`
Confidence float32 `protobuf:"fixed32,6,opt,name=confidence,proto3" json:"confidence,omitempty"`
@ -413,16 +423,16 @@ func (m *Object) GetType() TypeObject {
return TypeObject_ANY
}
func (m *Object) GetLLeft() int32 {
func (m *Object) GetLeft() int32 {
if m != nil {
return m.LLeft
return m.Left
}
return 0
}
func (m *Object) GetUp() int32 {
func (m *Object) GetTop() int32 {
if m != nil {
return m.Up
return m.Top
}
return 0
}
@ -487,6 +497,236 @@ func (m *SwitchRecordMessage) GetEnabled() bool {
return false
}
// Road description
type RoadMessage struct {
Contour []*Point `protobuf:"bytes,1,rep,name=contour,proto3" json:"contour,omitempty"`
Ellipse *Ellipse `protobuf:"bytes,2,opt,name=ellipse,proto3" json:"ellipse,omitempty"`
FrameRef *FrameRef `protobuf:"bytes,3,opt,name=frame_ref,json=frameRef,proto3" json:"frame_ref,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RoadMessage) Reset() { *m = RoadMessage{} }
func (m *RoadMessage) String() string { return proto.CompactTextString(m) }
func (*RoadMessage) ProtoMessage() {}
func (*RoadMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_8ec31f2d2a3db598, []int{8}
}
func (m *RoadMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RoadMessage.Unmarshal(m, b)
}
func (m *RoadMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RoadMessage.Marshal(b, m, deterministic)
}
func (m *RoadMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_RoadMessage.Merge(m, src)
}
func (m *RoadMessage) XXX_Size() int {
return xxx_messageInfo_RoadMessage.Size(m)
}
func (m *RoadMessage) XXX_DiscardUnknown() {
xxx_messageInfo_RoadMessage.DiscardUnknown(m)
}
var xxx_messageInfo_RoadMessage proto.InternalMessageInfo
func (m *RoadMessage) GetContour() []*Point {
if m != nil {
return m.Contour
}
return nil
}
func (m *RoadMessage) GetEllipse() *Ellipse {
if m != nil {
return m.Ellipse
}
return nil
}
func (m *RoadMessage) GetFrameRef() *FrameRef {
if m != nil {
return m.FrameRef
}
return nil
}
type Point struct {
X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"`
Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Point) Reset() { *m = Point{} }
func (m *Point) String() string { return proto.CompactTextString(m) }
func (*Point) ProtoMessage() {}
func (*Point) Descriptor() ([]byte, []int) {
return fileDescriptor_8ec31f2d2a3db598, []int{9}
}
func (m *Point) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Point.Unmarshal(m, b)
}
func (m *Point) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Point.Marshal(b, m, deterministic)
}
func (m *Point) XXX_Merge(src proto.Message) {
xxx_messageInfo_Point.Merge(m, src)
}
func (m *Point) XXX_Size() int {
return xxx_messageInfo_Point.Size(m)
}
func (m *Point) XXX_DiscardUnknown() {
xxx_messageInfo_Point.DiscardUnknown(m)
}
var xxx_messageInfo_Point proto.InternalMessageInfo
func (m *Point) GetX() int32 {
if m != nil {
return m.X
}
return 0
}
func (m *Point) GetY() int32 {
if m != nil {
return m.Y
}
return 0
}
type Ellipse struct {
Center *Point `protobuf:"bytes,1,opt,name=center,proto3" json:"center,omitempty"`
Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"`
Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"`
Angle float32 `protobuf:"fixed32,4,opt,name=angle,proto3" json:"angle,omitempty"`
Confidence float32 `protobuf:"fixed32,5,opt,name=confidence,proto3" json:"confidence,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Ellipse) Reset() { *m = Ellipse{} }
func (m *Ellipse) String() string { return proto.CompactTextString(m) }
func (*Ellipse) ProtoMessage() {}
func (*Ellipse) Descriptor() ([]byte, []int) {
return fileDescriptor_8ec31f2d2a3db598, []int{10}
}
func (m *Ellipse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Ellipse.Unmarshal(m, b)
}
func (m *Ellipse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Ellipse.Marshal(b, m, deterministic)
}
func (m *Ellipse) XXX_Merge(src proto.Message) {
xxx_messageInfo_Ellipse.Merge(m, src)
}
func (m *Ellipse) XXX_Size() int {
return xxx_messageInfo_Ellipse.Size(m)
}
func (m *Ellipse) XXX_DiscardUnknown() {
xxx_messageInfo_Ellipse.DiscardUnknown(m)
}
var xxx_messageInfo_Ellipse proto.InternalMessageInfo
func (m *Ellipse) GetCenter() *Point {
if m != nil {
return m.Center
}
return nil
}
func (m *Ellipse) GetWidth() int32 {
if m != nil {
return m.Width
}
return 0
}
func (m *Ellipse) GetHeight() int32 {
if m != nil {
return m.Height
}
return 0
}
func (m *Ellipse) GetAngle() float32 {
if m != nil {
return m.Angle
}
return 0
}
func (m *Ellipse) GetConfidence() float32 {
if m != nil {
return m.Confidence
}
return 0
}
// Record message used to tensorflow learning
type RecordMessage struct {
Frame *FrameMessage `protobuf:"bytes,1,opt,name=frame,proto3" json:"frame,omitempty"`
Steering *SteeringMessage `protobuf:"bytes,2,opt,name=steering,proto3" json:"steering,omitempty"`
RecordSet string `protobuf:"bytes,3,opt,name=recordSet,proto3" json:"recordSet,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RecordMessage) Reset() { *m = RecordMessage{} }
func (m *RecordMessage) String() string { return proto.CompactTextString(m) }
func (*RecordMessage) ProtoMessage() {}
func (*RecordMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_8ec31f2d2a3db598, []int{11}
}
func (m *RecordMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RecordMessage.Unmarshal(m, b)
}
func (m *RecordMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RecordMessage.Marshal(b, m, deterministic)
}
func (m *RecordMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_RecordMessage.Merge(m, src)
}
func (m *RecordMessage) XXX_Size() int {
return xxx_messageInfo_RecordMessage.Size(m)
}
func (m *RecordMessage) XXX_DiscardUnknown() {
xxx_messageInfo_RecordMessage.DiscardUnknown(m)
}
var xxx_messageInfo_RecordMessage proto.InternalMessageInfo
func (m *RecordMessage) GetFrame() *FrameMessage {
if m != nil {
return m.Frame
}
return nil
}
func (m *RecordMessage) GetSteering() *SteeringMessage {
if m != nil {
return m.Steering
}
return nil
}
func (m *RecordMessage) GetRecordSet() string {
if m != nil {
return m.RecordSet
}
return ""
}
func init() {
proto.RegisterEnum("robocar.events.DriveMode", DriveMode_name, DriveMode_value)
proto.RegisterEnum("robocar.events.TypeObject", TypeObject_name, TypeObject_value)
@ -498,40 +738,58 @@ func init() {
proto.RegisterType((*ObjectsMessage)(nil), "robocar.events.ObjectsMessage")
proto.RegisterType((*Object)(nil), "robocar.events.Object")
proto.RegisterType((*SwitchRecordMessage)(nil), "robocar.events.SwitchRecordMessage")
proto.RegisterType((*RoadMessage)(nil), "robocar.events.RoadMessage")
proto.RegisterType((*Point)(nil), "robocar.events.Point")
proto.RegisterType((*Ellipse)(nil), "robocar.events.Ellipse")
proto.RegisterType((*RecordMessage)(nil), "robocar.events.RecordMessage")
}
func init() { proto.RegisterFile("events/events.proto", fileDescriptor_8ec31f2d2a3db598) }
var fileDescriptor_8ec31f2d2a3db598 = []byte{
// 473 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x4d, 0x6b, 0xdb, 0x40,
0x10, 0x8d, 0x64, 0x5b, 0x96, 0x26, 0xc1, 0x15, 0x9b, 0x12, 0xd4, 0x1c, 0x4a, 0xd0, 0xc9, 0x04,
0xaa, 0x14, 0x97, 0x42, 0xaf, 0x4e, 0xd3, 0x82, 0xc1, 0x76, 0xcc, 0xda, 0x29, 0xb4, 0x97, 0xa0,
0x8f, 0x91, 0xad, 0x62, 0x6b, 0xc5, 0x6a, 0x93, 0xe2, 0x7b, 0x7f, 0x4e, 0x7f, 0x64, 0xd9, 0x5d,
0xad, 0x9b, 0xe8, 0xd2, 0x5e, 0x7a, 0xf2, 0xbc, 0xe7, 0x79, 0x6f, 0xdf, 0xce, 0x8e, 0xe0, 0x14,
0x1f, 0xb1, 0x14, 0xf5, 0x95, 0xfe, 0x89, 0x2a, 0xce, 0x04, 0x23, 0x03, 0xce, 0x12, 0x96, 0xc6,
0x3c, 0xd2, 0x6c, 0x18, 0x81, 0xfb, 0x99, 0xc7, 0x3b, 0xa4, 0x98, 0x13, 0x02, 0xdd, 0x32, 0xde,
0x61, 0x60, 0x5d, 0x58, 0x43, 0x8f, 0xaa, 0x9a, 0x0c, 0xc0, 0x2e, 0xb2, 0xc0, 0x56, 0x8c, 0x5d,
0x64, 0xe1, 0x1c, 0x4e, 0x54, 0xff, 0x0c, 0xeb, 0x3a, 0x5e, 0x23, 0x19, 0xaa, 0xff, 0xa5, 0xe2,
0x78, 0x14, 0x44, 0xcf, 0xcd, 0x23, 0xe3, 0x2c, 0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5e,
0xac, 0x37, 0x22, 0xe8, 0xea, 0x2e, 0x05, 0xc8, 0x19, 0x38, 0x09, 0x13, 0x82, 0xed, 0x82, 0x9e,
0xa2, 0x1b, 0xd4, 0x7a, 0x2e, 0xa7, 0xfd, 0x5c, 0xe1, 0x15, 0x9c, 0x2e, 0x7f, 0x14, 0x22, 0xdd,
0x50, 0x4c, 0x19, 0xcf, 0xcc, 0xb8, 0x02, 0xe8, 0x63, 0x19, 0x27, 0x5b, 0xd4, 0x1b, 0xee, 0x52,
0x03, 0x2f, 0xdf, 0x80, 0x77, 0x18, 0x39, 0x39, 0x86, 0xfe, 0x64, 0xfe, 0x65, 0x3c, 0x9d, 0xdc,
0xf8, 0x47, 0xc4, 0x85, 0xee, 0xdd, 0xf2, 0x13, 0xf5, 0x2d, 0xe2, 0x41, 0x6f, 0x31, 0x99, 0xde,
0xae, 0x7c, 0xfb, 0x72, 0x04, 0xf0, 0xe7, 0x9e, 0xa4, 0x0f, 0x9d, 0xf1, 0xfc, 0xab, 0x7f, 0x24,
0x8b, 0x8f, 0x63, 0xd9, 0xea, 0x42, 0xf7, 0xfa, 0x6e, 0xb6, 0xf0, 0x6d, 0x59, 0x2d, 0xa4, 0xa6,
0x73, 0xed, 0x7e, 0x73, 0xf4, 0x88, 0x12, 0x47, 0x7d, 0xba, 0xef, 0x7e, 0x07, 0x00, 0x00, 0xff,
0xff, 0x77, 0x9d, 0xdb, 0x75, 0xd1, 0x03, 0x00, 0x00,
// 696 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x5b, 0x6f, 0x12, 0x51,
0x10, 0xee, 0x2e, 0x2c, 0xb0, 0x43, 0x45, 0x72, 0xaa, 0x75, 0x25, 0x8d, 0x6d, 0xf0, 0x85, 0x34,
0xe9, 0xa2, 0x18, 0x13, 0x8d, 0x4f, 0xd4, 0xd6, 0xa4, 0x49, 0x2f, 0xe4, 0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, 0x72, 0xe9, 0xad, 0x63, 0x77, 0x0f,
0xdc, 0xe5, 0x27, 0x48, 0xaa, 0x50, 0x3e, 0x3a, 0xfd, 0xd8, 0x3d, 0x3e, 0x3a, 0xa8, 0xaf, 0x91,
0x0a, 0x14, 0xcf, 0xfb, 0x87, 0xb4, 0x6e, 0x11, 0x17, 0x9c, 0xde, 0xd1, 0xf1, 0xd9, 0xa0, 0x6e,
0xef, 0x76, 0x00, 0x6e, 0xdf, 0x3d, 0x29, 0x43, 0xa1, 0x7b, 0xfa, 0xa9, 0xbe, 0x96, 0x19, 0xef,
0xbb, 0x59, 0x68, 0x05, 0x8a, 0xfb, 0xe7, 0x27, 0xbd, 0xba, 0x9d, 0x59, 0xbd, 0x2c, 0xa7, 0xb0,
0x5f, 0xf9, 0x5c, 0x52, 0x22, 0x87, 0x25, 0x79, 0xa2, 0x5f, 0xfd, 0x0a, 0x00, 0x00, 0xff, 0xff,
0x5d, 0x6e, 0x23, 0x4e, 0x3d, 0x06, 0x00, 0x00,
}

View File

@ -393,7 +393,7 @@ func (p *Buffer) Bytes() []byte { return p.buf }
// than relying on this API.
//
// If deterministic serialization is requested, map entries will be sorted
// by keys in lexographical order. This is an implementation detail and
// by keys in lexicographical order. This is an implementation detail and
// subject to change.
func (p *Buffer) SetDeterministic(deterministic bool) {
p.deterministic = deterministic

View File

@ -456,6 +456,8 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return nil
}
var textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
// writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
@ -519,8 +521,8 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
// mutating this value.
v = v.Addr()
}
if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := etm.MarshalText()
if v.Type().Implements(textMarshalerType) {
text, err := v.Interface().(encoding.TextMarshaler).MarshalText()
if err != nil {
return err
}

View File

@ -0,0 +1,185 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: google/protobuf/timestamp.proto
package timestamp
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at
// nanosecond resolution. The count is relative to an epoch at UTC midnight on
// January 1, 1970, in the proleptic Gregorian calendar which extends the
// Gregorian calendar backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a [24-hour linear
// smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from [RFC
// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
//
// Example 5: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required. A proto3 JSON serializer should always use UTC (as indicated by
// "Z") when printing the Timestamp type and a proto3 JSON parser should be
// able to accept both UTC and other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
// the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
// ) to obtain a formatter capable of generating timestamps in this format.
//
//
type Timestamp struct {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Timestamp) Reset() { *m = Timestamp{} }
func (m *Timestamp) String() string { return proto.CompactTextString(m) }
func (*Timestamp) ProtoMessage() {}
func (*Timestamp) Descriptor() ([]byte, []int) {
return fileDescriptor_292007bbfe81227e, []int{0}
}
func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
func (m *Timestamp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Timestamp.Unmarshal(m, b)
}
func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic)
}
func (m *Timestamp) XXX_Merge(src proto.Message) {
xxx_messageInfo_Timestamp.Merge(m, src)
}
func (m *Timestamp) XXX_Size() int {
return xxx_messageInfo_Timestamp.Size(m)
}
func (m *Timestamp) XXX_DiscardUnknown() {
xxx_messageInfo_Timestamp.DiscardUnknown(m)
}
var xxx_messageInfo_Timestamp proto.InternalMessageInfo
func (m *Timestamp) GetSeconds() int64 {
if m != nil {
return m.Seconds
}
return 0
}
func (m *Timestamp) GetNanos() int32 {
if m != nil {
return m.Nanos
}
return 0
}
func init() {
proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
}
func init() {
proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_292007bbfe81227e)
}
var fileDescriptor_292007bbfe81227e = []byte{
// 191 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f,
0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d,
0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28,
0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5,
0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89,
0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x1d, 0x97, 0x70,
0x72, 0x7e, 0xae, 0x1e, 0x9a, 0x99, 0x4e, 0x7c, 0x70, 0x13, 0x03, 0x40, 0x42, 0x01, 0x8c, 0x51,
0xda, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0x39, 0x89,
0x79, 0xe9, 0x08, 0x27, 0x16, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x23, 0x5c, 0xfa, 0x83, 0x91, 0x71,
0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xc9, 0x01, 0x50, 0xb5, 0x7a,
0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x3d, 0x49, 0x6c, 0x60, 0x43,
0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x77, 0x4a, 0x07, 0xf7, 0x00, 0x00, 0x00,
}

View File

@ -0,0 +1,138 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "github.com/golang/protobuf/ptypes/timestamp";
option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at
// nanosecond resolution. The count is relative to an epoch at UTC midnight on
// January 1, 1970, in the proleptic Gregorian calendar which extends the
// Gregorian calendar backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a [24-hour linear
// smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from [RFC
// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
//
// Example 5: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required. A proto3 JSON serializer should always use UTC (as indicated by
// "Z") when printing the Timestamp type and a proto3 JSON parser should be
// able to accept both UTC and other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
// the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
// ) to obtain a formatter capable of generating timestamps in this format.
//
//
message Timestamp {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1;
// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
int32 nanos = 2;
}

9
vendor/modules.txt vendored
View File

@ -1,16 +1,15 @@
# github.com/cyrilix/robocar-base v0.0.0-20200101163959-0a3e47f0016b
# github.com/cyrilix/robocar-base v0.1.0
github.com/cyrilix/robocar-base/cli
github.com/cyrilix/robocar-base/mqttdevice
github.com/cyrilix/robocar-base/service
github.com/cyrilix/robocar-base/testtools
github.com/cyrilix/robocar-base/types
# github.com/cyrilix/robocar-protobuf/go v0.0.0-20200101000356-accf7184079a
# github.com/cyrilix/robocar-protobuf/go v1.0.0
github.com/cyrilix/robocar-protobuf/go/events
# github.com/eclipse/paho.mqtt.golang v1.2.0
github.com/eclipse/paho.mqtt.golang
github.com/eclipse/paho.mqtt.golang/packets
# github.com/golang/protobuf v1.3.2
# github.com/golang/protobuf v1.3.4
github.com/golang/protobuf/proto
github.com/golang/protobuf/ptypes/timestamp
# github.com/konsorten/go-windows-terminal-sequences v1.0.2
github.com/konsorten/go-windows-terminal-sequences
# github.com/sirupsen/logrus v1.4.2