Commit 1d1e8558 authored by Kevin Lyda's avatar Kevin Lyda 💬

Work on GetConfiguration.

parent 93892a8e
Pipeline #1230 passed with stage
in 54 seconds
......@@ -36,20 +36,23 @@ func main() {
t, err = gc.GetTime()
if err != nil {
fmt.Printf("Failed: '%s'\n", err)
} else {
fmt.Printf("Time: %s\n", t)
}
fmt.Printf("Time: %s\n", t)
cpm, err = gc.GetCPM()
if err != nil {
fmt.Printf("CPM failed: '%s'\n", err)
} else {
fmt.Printf("CPM: %d\n", cpm)
}
fmt.Printf("CPM: %d\n", cpm)
cps, err = gc.GetCPS()
if err != nil {
fmt.Printf("CPS failed: '%s'\n", err)
} else {
fmt.Printf("CPS: %d\n", cps)
}
fmt.Printf("CPS: %d\n", cps)
fmt.Printf("Version: %s\n", gc.Version())
fmt.Printf("Model: %s\n", gc.Model())
......@@ -58,15 +61,20 @@ func main() {
volts, err = gc.Volts()
if err != nil {
fmt.Printf("Volts failed: '%s'\n", err)
} else {
fmt.Printf("Volts: %d\n", volts)
}
fmt.Printf("Volts: %d\n", volts)
temp, err = gc.GetTemp()
if err != nil {
fmt.Printf("Temp failed: '%s'\n", err)
} else {
fmt.Printf("Temp: %g\n", temp)
}
fmt.Printf("Temp: %g\n", temp)
gc.GetConfiguration()
err = gc.GetConfiguration()
if err != nil {
fmt.Printf("Failed to get config: '%s'\n", err)
}
}
......@@ -32,7 +32,7 @@ type Counter interface {
TurnOffCPS() error
GetAutoCPS() (uint16, error)
TurnOffPower()
GetConfiguration()
GetConfiguration() error
SetConfiguration()
SetTime(time.Time)
GetTime() (time.Time, error)
......
......@@ -235,19 +235,20 @@ func (gc *GQGMCCounter) TurnOffPower() {
}
// GetConfiguration reads configuration data
func (gc *GQGMCCounter) GetConfiguration() {
func (gc *GQGMCCounter) GetConfiguration() error {
if !gc.supportedModels(mod280n300) {
return
return errors.New("Unsupported Model")
}
if gc.versionLT("Re 2.10") {
return
return errors.New("Unsupported version")
}
cfg, err := gc.communicate(cmdGetCfg, 256)
if err != nil {
return
return err
}
fmt.Printf("%+v\n", cfg)
fmt.Printf("Configuration: %+v\n", cfg)
return nil
}
// SetConfiguration writes configuration data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment