-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patharm_status.go
40 lines (37 loc) · 1.05 KB
/
arm_status.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
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
arm_fails := [...]string{"", "",
"Armed",
"Ever Armed",
"HITL",
"SITL",
"Geozone",
"Failsafe", "Not level", "Calibrating", "Overload",
"Navigation unsafe", "Compass cal", "Acc cal", "Arm switch", "Hardware failure",
"Box failsafe", "Box killswitch", "RC Link", "Throttle", "CLI",
"CMS Menu", "OSD Menu", "Roll/Pitch", "Servo Autotrim", "Out of memory",
"Settings", "PWM Output", "PreArm", "DSHOTBeeper", "Landing", "Other"}
if len(os.Args) > 1 {
for _, a := range os.Args[1:] {
if v, err := strconv.ParseInt(a, 16, 64); err == nil {
fmt.Printf("Status %08x:\n", v)
for i := 0; i < 32; i++ {
if (v & (1 << i)) != 0 {
if i < len(arm_fails) && arm_fails[i] != "" {
fmt.Printf(" %08x => %s\n", (1 << i), arm_fails[i])
}
}
}
} else {
fmt.Fprintf(os.Stderr, "Failed to parse \"%s\" as a valid status hexadecimal value\n", os.Args[1])
}
}
} else {
fmt.Fprintln(os.Stderr, "arm_status: requires at least one integer argument")
}
}