Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for minion ID before making salt call #27

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Go CI and Release

on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- '**'

jobs:
build:
uses: TheCacophonyProject/github-actions-templates/.github/workflows/[email protected]
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project_name: modemd

version: 2

release:
github:
owner: TheCacophonyProject
Expand Down
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions _release/modemd.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Cacophony Project USB modem controller
After=multi-user.target
ConditionPathExists=/etc/salt/minion_id

[Service]
Type=simple
Expand Down
7 changes: 4 additions & 3 deletions cmd/check-gps/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -211,7 +210,7 @@ func runATCommand(atCommand string) (string, error) {
// ConvertLong converts a longitude in format dddmm.mmmmmm to degrees.
func ConvertLong(long string) (float64, error) {
if len(long) < 7 {
return 0, fmt.Errorf("Invalid longitude format")
return 0, fmt.Errorf("invalid longitude format")
}

// Split the longitude string into degrees and minutes.
Expand All @@ -237,7 +236,7 @@ func ConvertLong(long string) (float64, error) {
// ConvertLat converts a latitude in format ddmm.mmmmmm to degrees.
func ConvertLat(lat string) (float64, error) {
if len(lat) < 6 {
return 0, fmt.Errorf("Invalid latitude format")
return 0, fmt.Errorf("invalid latitude format")
}

// Split the latitude string into degrees and minutes.
Expand All @@ -260,6 +259,7 @@ func ConvertLat(lat string) (float64, error) {
return degrees + minutesInDegrees, nil
}

/*
func appendToFile(filename string, data string) error {
// Open the file in append mode or create if it doesn't exist
file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
Expand All @@ -272,3 +272,4 @@ func appendToFile(filename string, data string) error {
_, err = file.WriteString(data + "\n")
return err
}
*/
4 changes: 4 additions & 0 deletions cmd/modemd/modemController.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

"github.com/TheCacophonyProject/event-reporter/v3/eventclient"
goconfig "github.com/TheCacophonyProject/go-config"
"github.com/TheCacophonyProject/go-utils/saltutil"
"github.com/tarm/serial"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
Expand Down Expand Up @@ -886,6 +887,9 @@ func saltCommandsRunning() bool {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()

if !saltutil.IsSaltIdSet() {
return false
}
cmd := exec.CommandContext(ctx, "salt-call", "--local", "saltutil.running")

stdout, err := cmd.Output()
Expand Down
4 changes: 2 additions & 2 deletions cmd/reception-logger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ var log = logging.NewLogger("info")

func main() {
for {
out, err := runATCommand("AT")
_, err := runATCommand("AT")
if err != nil {
log.Fatal(err)
}
reception := readReception()
band, _ := readBand()
t := time.Now().Format("2006-01-02 15:04:05")
out = fmt.Sprintf("%s, %s, %s", t, reception, band)
out := fmt.Sprintf("%s, %s, %s", t, reception, band)
log.Println(out)
appendToFile("/home/pi/reception", out)
time.Sleep(5 * time.Second)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.3
require (
github.com/TheCacophonyProject/event-reporter/v3 v3.8.0
github.com/TheCacophonyProject/go-config v1.9.1
github.com/TheCacophonyProject/go-utils v0.1.1
github.com/TheCacophonyProject/go-utils v0.1.3
github.com/alexflint/go-arg v1.4.2
github.com/godbus/dbus v4.1.0+incompatible
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/TheCacophonyProject/go-config v0.0.0-20190922224052-7c2a21bc6b88/go.m
github.com/TheCacophonyProject/go-config v1.9.0/go.mod h1:+y80PSRZudMYuVrYTGOvzc66NxVJWKS4TuU442vmvhY=
github.com/TheCacophonyProject/go-config v1.9.1 h1:TCeogtNYg5eHx2q97DQ1B+RsbjacW+jr7h1TCv1FpAk=
github.com/TheCacophonyProject/go-config v1.9.1/go.mod h1:XZwQmNl2wQXhYR18RQtwZ6LwFwgAx73yzJfymYLz68s=
github.com/TheCacophonyProject/go-utils v0.1.1 h1:VOt9EphEqRUYMqKJlJeliIarIMlCVKYGb1fdqM6b4YM=
github.com/TheCacophonyProject/go-utils v0.1.1/go.mod h1:jZPUZ4GtYVxnlTtqiYKMFWDT//kmxdbwjLW3HCyCmCE=
github.com/TheCacophonyProject/go-utils v0.1.3 h1:DSuDeJz7ZM00yQRLsoukWH0fnC+8X8+ziYxOl6l3wEY=
github.com/TheCacophonyProject/go-utils v0.1.3/go.mod h1:jZPUZ4GtYVxnlTtqiYKMFWDT//kmxdbwjLW3HCyCmCE=
github.com/TheCacophonyProject/modemd v0.0.0-20190605010435-ae5b0f2eb760/go.mod h1:bfwJ/WcvDY9XtHKC5tcRfVrU8RWaW8DLYAAUfsrJr/4=
github.com/TheCacophonyProject/modemd v1.6.0/go.mod h1:0M7yJCdqhvoI5dVeDjOH6vsmbOBr1YhZ8DpAK4AkOA0=
github.com/TheCacophonyProject/window v0.0.0-20190821235241-ab92c2ee24b6/go.mod h1:Vww417iimOb0s46Ndsm8U/vYtwc0dZUet4uW8QzBo4M=
Expand Down