Browse Source

Fixed changes from upstream interface

motorcontrol
Tim Schuster 2 years ago
parent
commit
73dd643cde
Signed by: Tim Schuster <mail@timschuster.info> GPG Key ID: F9E27097EFB77F61
3 changed files with 29 additions and 7 deletions
  1. 4
    1
      chc.go
  2. 1
    1
      con.go
  3. 24
    5
      direct.go

+ 4
- 1
chc.go View File

@@ -37,7 +37,10 @@ func connect(params []string) error {
37 37
 	}
38 38
 	fmt.Printf("Using Config Path %s\n", path)
39 39
 	logger := log.New(os.Stderr, "CHC", log.Lshortfile | log.LUTC)
40
-	hc := HardwareControl.NewHardwareControl(logger, path)
40
+	hc, err := HardwareControl.NewHardwareControl(logger, path)
41
+	if err != nil {
42
+		return errors.Wrap(err, "Could not connect to CHC")
43
+	}
41 44
 	curCHC = hc
42 45
 	return nil
43 46
 }

+ 1
- 1
con.go View File

@@ -7,7 +7,7 @@ import (
7 7
 	"git.timschuster.info/stephan.graf/Complete_hardware_Control"
8 8
 )
9 9
 
10
-var curCHC *HardwareControl.HardwareControl
10
+var curCHC HardwareControl.HardwareControlInterface
11 11
 
12 12
 func Run() {
13 13
 	bufin := bufio.NewReader(os.Stdin)

+ 24
- 5
direct.go View File

@@ -29,7 +29,12 @@ func manhome(params []string) error {
29 29
 		fmt.Println("CHC not connected, aborting.")
30 30
 		return nil
31 31
 	}
32
-	return curCHC.ThreeDControl.Movehome()
32
+	tdc := curCHC.GetThreeDControl()
33
+	if tdc == nil {
34
+		fmt.Println("Hardware Controller does not support Direct 3D Access")
35
+		return nil
36
+	}
37
+	return tdc.Movehome()
33 38
 }
34 39
 
35 40
 func manxyz(params []string) error {
@@ -53,9 +58,13 @@ func manxyz(params []string) error {
53 58
 	return errors.Wrap(err, "Error while parsing Z")
54 59
 	}
55 60
 	}
56
-
57 61
 	fmt.Printf("Moving manually to %5.1f %5.1f %5.1f\n", x, y, z)
58
-	return curCHC.ThreeDControl.Moveto(x,y,z)
62
+	tdc := curCHC.GetThreeDControl()
63
+	if tdc == nil {
64
+		fmt.Println("Hardware Controller does not support Direct 3D Access")
65
+		return nil
66
+	}
67
+	return tdc.Moveto(x,y,z)
59 68
 }
60 69
 
61 70
 func mancon(params []string) error {
@@ -72,7 +81,12 @@ func getcoords(params []string) error {
72 81
 		fmt.Println("CHC not connected, aborting.")
73 82
 		return nil
74 83
 	}
75
-	x,y,z, err := curCHC.ThreeDControl.Getposition(false)
84
+	tdc := curCHC.GetThreeDControl()
85
+	if tdc == nil {
86
+		fmt.Println("Hardware Controller does not support Direct 3D Access")
87
+		return nil
88
+	}
89
+	x,y,z, err := tdc.Getposition(false)
76 90
 	if err != nil {
77 91
 		return errors.Wrap(err, "Could not get position")
78 92
 	}
@@ -110,5 +124,10 @@ func step(params []string) error {
110 124
 		}
111 125
 	}
112 126
 
113
-	return curCHC.ThreeDControl.Singlestep(moveX, moveY, moveZ, stepLength, reverse)
127
+	tdc := curCHC.GetThreeDControl()
128
+	if tdc == nil {
129
+		fmt.Println("Hardware Controller does not support Direct 3D Access")
130
+		return nil
131
+	}
132
+	return tdc.Singlestep(moveX, moveY, moveZ, stepLength, reverse)
114 133
 }

Loading…
Cancel
Save