-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (40 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// package main is a module with raspberry pi board component.
package main
import (
"context"
"github.com/viam-modules/gps/nmea"
"github.com/viam-modules/gps/rtk"
dualgps "github.com/viam-modules/gps/rtk-dual-gps"
"go.viam.com/rdk/components/movementsensor"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/module"
"go.viam.com/utils"
)
func main() {
utils.ContextualMain(mainWithArgs, module.NewLoggerFromArgs("gps"))
}
func mainWithArgs(ctx context.Context, args []string, logger logging.Logger) error {
module, err := module.NewModuleFromArgs(ctx)
if err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, rtk.ModelSerial); err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, rtk.ModelPmtk); err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, nmea.Model); err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, dualgps.Model); err != nil {
return err
}
err = module.Start(ctx)
defer module.Close(ctx)
if err != nil {
return err
}
<-ctx.Done()
return nil
}