@@ -7,10 +7,10 @@ import (
77 "os/exec"
88 "strings"
99
10- "github.com/wilriker/goduetapiclient /commands"
11- "github.com/wilriker/goduetapiclient /connection"
12- "github.com/wilriker/goduetapiclient /connection/initmessages"
13- "github.com/wilriker/goduetapiclient /types"
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"
1414)
1515
1616const (
@@ -22,9 +22,10 @@ type Executor struct {
2222 mCodes map [int64 ]int
2323 commands Commands
2424 debug bool
25+ trace bool
2526}
2627
27- func NewExecutor (socketPath string , commands Commands , mCodes MCodes , debug bool ) * Executor {
28+ func NewExecutor (socketPath string , commands Commands , mCodes MCodes , debug , trace bool ) * Executor {
2829 mc := make (map [int64 ]int )
2930 for i , m := range mCodes {
3031 mc [m ] = i
@@ -41,15 +42,17 @@ func NewExecutor(socketPath string, commands Commands, mCodes MCodes, debug bool
4142 mCodes : mc ,
4243 commands : commands ,
4344 debug : debug ,
45+ trace : trace ,
4446 }
4547}
4648
47- func (e * Executor ) Run () {
49+ func (e * Executor ) Run () error {
4850
4951 ic := connection.InterceptConnection {}
52+ ic .Debug = e .trace
5053 err := ic .Connect (initmessages .InterceptionModePre , e .socketPath )
5154 if err != nil {
52- log . Fatal ( err )
55+ return err
5356 }
5457 defer ic .Close ()
5558
@@ -58,7 +61,12 @@ func (e *Executor) Run() {
5861 if err != nil {
5962 if err == io .EOF {
6063 log .Println ("Connection to DCS closed" )
61- break
64+ return err
65+ }
66+ if _ , ok := err .(* connection.DecodeError ); ok {
67+ // If it is "just" a problem with decoding ignore the received code
68+ // as it otherwise will block DCS
69+ ic .IgnoreCode ()
6270 }
6371 log .Printf ("Error receiving code: %s" , err )
6472 continue
0 commit comments