-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteeloader-cli.go
99 lines (90 loc) · 2.08 KB
/
teeloader-cli.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"github.com/neonsoftware/teeloader-go/teeloader"
"fmt"
"github.com/codegangsta/cli"
"os"
)
func main() {
// This software structure is described in the README of the command line interface library github.com/codegangsta/cli
app := cli.NewApp()
app.Name = "teeloader-osx-cli"
app.Author = "Francesco Cervigni from Paul J Stoffregen's Teensy Loader 2.0"
app.Usage = "Teensy firmware loader"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "mcu",
Value: "mk20dx256",
Usage: "Teensy chip",
},
cli.StringFlag{
Name: "file, f",
Usage: "Input hefx file",
},
cli.StringFlag{
Name: "vendorId",
Value: "0x16c0",
Usage: "USB Vendor ID",
},
cli.StringFlag{
Name: "productId",
Value: "0x0486",
Usage: "USB Product ID",
},
cli.BoolFlag{
Name: "verbose, V",
Usage: "Verbose",
},
cli.BoolFlag{
Name: "wait, w",
Usage: "Wait",
},
cli.BoolFlag{
Name: "hardreboot, r",
Usage: "Hard Reboot",
},
cli.BoolFlag{
Name: "noreboot, n",
Usage: "No Reboot",
},
cli.BoolFlag{
Name: "l",
Usage: "List all Teensy USB devices",
},
}
app.Action = func(c *cli.Context) {
verbose := 0
wait := 1
hardreboot := 0
noreboot := 0
listActive := false
if c.Bool("l") {
fmt.Println("\n\n\tList mode active.\n")
//teensys := teeloader.GetConnectedUSBTeensy()
//fmt.Println("\tTeensy Devices List : Size : ", len(teensys), " - Strings : ", teensys, "\n" )
listActive = true
}
if c.String("file") == "" && !listActive {
fmt.Println("\n\tPlease specify input hex file with --file or -f\n")
return
}
if c.Bool("V") {
fmt.Println("\n\tVerbose mode active.\n")
verbose = 1
}
if c.Bool("w") {
fmt.Println("\n\tVerbose mode active.\n")
wait = 1
}
if c.Bool("r") {
fmt.Println("\n\tVerbose mode active.\n")
hardreboot = 1
}
if c.Bool("n") {
fmt.Println("\n\tVerbose mode active.\n")
noreboot = 1
}
teeloader.Teensy_load(c.String("mcu"), c.String("vendorId"), c.String("productId"), c.String("file"), wait, hardreboot, noreboot, verbose)
}
app.Run(os.Args)
}