Skip to content
This repository was archived by the owner on Sep 5, 2022. It is now read-only.

Commit 7d880dd

Browse files
committed
Update to godsfapi 2.1.0
1 parent ce73807 commit 7d880dd

4 files changed

Lines changed: 34 additions & 12 deletions

File tree

cmd/eom/execonmcode.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ package main
33
import (
44
"flag"
55
"log"
6+
"os"
67

7-
"github.com/Duet3D/DSF-APIs/godsfapi/connection"
8+
"github.com/Duet3D/DSF-APIs/godsfapi/v2/connection"
89
"github.com/wilriker/execonmcode"
910
)
1011

12+
const (
13+
version = "5.0"
14+
)
15+
1116
type settings struct {
1217
socketPath string
1318
mCodes execonmcode.MCodes
@@ -25,8 +30,14 @@ func main() {
2530
flag.Var(&s.commands, "command", "Command to execute")
2631
flag.BoolVar(&s.debug, "debug", false, "Print debug output")
2732
flag.BoolVar(&s.trace, "trace", false, "Print underlying requests/responses")
33+
version := flag.Bool("version", false, "Show version and exit")
2834
flag.Parse()
2935

36+
if *version {
37+
log.Println(version)
38+
os.Exit(0)
39+
}
40+
3041
if s.mCodes.Len() != s.commands.Len() {
3142
log.Fatal("Unequal amount of M-codes and commands given")
3243
}

executor.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"os/exec"
88
"strings"
99

10-
"github.com/Duet3D/DSF-APIs/godsfapi/commands"
11-
"github.com/Duet3D/DSF-APIs/godsfapi/connection"
12-
"github.com/Duet3D/DSF-APIs/godsfapi/connection/initmessages"
13-
"github.com/Duet3D/DSF-APIs/godsfapi/types"
10+
"github.com/Duet3D/DSF-APIs/godsfapi/v2/commands"
11+
"github.com/Duet3D/DSF-APIs/godsfapi/v2/connection"
12+
"github.com/Duet3D/DSF-APIs/godsfapi/v2/connection/initmessages"
13+
"github.com/Duet3D/DSF-APIs/godsfapi/v2/machine/messages"
1414
)
1515

1616
const (
@@ -71,25 +71,31 @@ func (e *Executor) Run() error {
7171
log.Printf("Error receiving code: %s", err)
7272
continue
7373
}
74-
if c.Type == types.MCode && c.MajorNumber != nil {
74+
if c.Type == commands.MCode && c.MajorNumber != nil {
7575
i, ok := e.mCodes[*c.MajorNumber]
7676
if !ok {
7777
ic.IgnoreCode()
7878
continue
7979
}
80+
success, err := ic.Flush(c.Channel)
81+
if !success || err != nil {
82+
log.Println("Could not Flush. Cancelling code")
83+
ic.CancelCode()
84+
continue
85+
}
8086
comd, a, err := e.commands.Get(i)
8187
if err != nil {
82-
ic.ResolveCode(types.Error, err.Error())
88+
ic.ResolveCode(messages.Error, err.Error())
8389
} else {
8490
cmd := exec.Command(comd, e.getArgs(c, a)...)
8591
if e.debug {
8692
log.Println("Executing:", cmd)
8793
}
8894
output, err := cmd.CombinedOutput()
8995
if err != nil {
90-
err = ic.ResolveCode(types.Error, fmt.Sprintf("%s: %s", err.Error(), string(output)))
96+
err = ic.ResolveCode(messages.Error, fmt.Sprintf("%s: %s", err.Error(), string(output)))
9197
} else {
92-
err = ic.ResolveCode(types.Success, "")
98+
err = ic.ResolveCode(messages.Success, "")
9399
}
94100
if err != nil {
95101
log.Println("Error executing command:", err)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/wilriker/execonmcode
22

33
go 1.14
44

5-
require github.com/Duet3D/DSF-APIs/godsfapi v0.0.0-20200406084749-1671ee2a95ae
5+
require github.com/Duet3D/DSF-APIs/godsfapi/v2 v2.0.0-20200422123133-670706fea346

go.sum

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
github.com/Duet3D/DSF-APIs/godsfapi v0.0.0-20200406084749-1671ee2a95ae h1:+T8uabIU7Tp8alI/II5MdX9W3iSLYWOsH5bhbw225Yk=
2-
github.com/Duet3D/DSF-APIs/godsfapi v0.0.0-20200406084749-1671ee2a95ae/go.mod h1:Pr9LdwVqZpjqHTUKaWmzCCWzk2jn1QaLTPaDF6UKlWo=
1+
github.com/Duet3D/DSF-APIs v1.2.4 h1:J5ez7gAEzQdxqLMgBy2+EY5xCQIlDJM+Xt0HR80+L/0=
2+
github.com/Duet3D/DSF-APIs v2.1.0+incompatible h1:UW9VZATPRJRXvbP1vBpiNL9S/iUzTucB0C6n95jXamA=
3+
github.com/Duet3D/DSF-APIs/godsfapi v0.0.0-20200422123133-670706fea346 h1:Qjo7CFDbeW2cVjn/iBbbx3gcjecHPKiWDcpkVDdADTg=
4+
github.com/Duet3D/DSF-APIs/godsfapi/v2 v2.0.0-20200422123133-670706fea346 h1:wC9h+UN3xETa7xlkEAJyvBwpfVD2zB7H1d4kvni49bw=
5+
github.com/Duet3D/DSF-APIs/godsfapi/v2 v2.0.0-20200422123133-670706fea346/go.mod h1:4MbBdIOM6SlzCSvtSjpeAj2S62ANmW0fFHeOk8SpjXw=
6+
github.com/mitchellh/mapstructure v1.2.2 h1:dxe5oCinTXiTIcfgmZecdCzPmAJKd46KsCWc35r0TV4=
7+
github.com/mitchellh/mapstructure v1.2.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=

0 commit comments

Comments
 (0)