Skip to content

Commit 0eb5da9

Browse files
committed
Add cli command to flash the test application.
1 parent cfdba80 commit 0eb5da9

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

cmd/flashTest.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2025 Blake Felt [email protected]
3+
4+
This Source Code Form is subject to the terms of the Mozilla Public
5+
License, v. 2.0. If a copy of the MPL was not distributed with this
6+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*/
8+
package cmd
9+
10+
import (
11+
"fmt"
12+
"os"
13+
14+
"github.com/Molorius/ulp-c/pkg/usb"
15+
"github.com/spf13/cobra"
16+
)
17+
18+
var flashTestCmd = &cobra.Command{
19+
Use: "flash_test",
20+
Short: "Flash the test application",
21+
Long: `flash_test is used to write the test application
22+
to the flash of an esp32. The test application can be used
23+
for unit tests or for general debugging of the ULP.
24+
25+
It requires the serial port that the esp32 is connected to.
26+
Requires that esptool.py is installed.
27+
28+
Example:
29+
ulp-forth flash_test /dev/tty.usbserial-0001`,
30+
Run: func(cmd *cobra.Command, args []string) {
31+
if len(args) == 0 {
32+
cmd.Help()
33+
os.Exit(0)
34+
}
35+
if len(args) != 1 {
36+
fmt.Printf("only port expected, %d arguments passed in\r\n", len(args))
37+
os.Exit(1)
38+
}
39+
40+
port := args[0]
41+
err := usb.WriteTestApp(port)
42+
if err != nil {
43+
fmt.Printf("%s", err)
44+
os.Exit(1)
45+
}
46+
},
47+
}
48+
49+
func init() {
50+
rootCmd.AddCommand(flashTestCmd)
51+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/Molorius/ulp-forth
33
go 1.23.1
44

55
require (
6-
github.com/Molorius/ulp-c v0.0.0-20250112212541-2dbe62a47c98
6+
github.com/Molorius/ulp-c v0.0.0
77
github.com/ergochat/readline v0.1.3
88
github.com/spf13/cobra v1.8.1
99
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/Molorius/ulp-c v0.0.0-20250112212541-2dbe62a47c98 h1:kZEwdeX2wcsTdj6pAnUrBJSvy0vcNFIXFRPXrUzAM60=
2-
github.com/Molorius/ulp-c v0.0.0-20250112212541-2dbe62a47c98/go.mod h1:rVuR1Qx8CLS46V7nSIC0e7c/RATu106KbqEvcFnKH9I=
1+
github.com/Molorius/ulp-c v0.0.0 h1:8ETXA8SrMtCltGIe3DJ8ueCuhj+WUijM7GOkg0uf6TM=
2+
github.com/Molorius/ulp-c v0.0.0/go.mod h1:VrWdBaBBrwsJ3JhzftY7Ed6N+cxu7yHGpUBBk207ejM=
33
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
44
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
55
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=

0 commit comments

Comments
 (0)