Skip to content
Snippets Groups Projects
Commit 616f1be2 authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

Add new commands.

parent 66b148da
Branches
No related tags found
No related merge requests found
......@@ -34,7 +34,10 @@ type Counter interface {
GetConfiguration()
SetConfiguration()
ResetConfiguration()
SetTime(t time.Time)
SetTime(time.Time)
GetTime() (time.Time, error)
FactoryReset()
Reboot()
}
// Config contain the configuration for a Geiger Counter
......
......@@ -114,6 +114,9 @@ const (
cmdTurnOnCPS = "<HEARTBEAT1>>"
cmdTurnOffCPS = "<HEARTBEAT0>>"
cmdTurnOffPwr = "<POWEROFF>>"
cmdFactoryReset = "<FACTORYRESET>>"
cmdReboot = "<REBOOT>>"
cmdGetTime = "<GETDATETIME>>"
)
// GQGMCCounter is a GQ GMC Counter
......@@ -275,6 +278,9 @@ func (gc *GQGMCCounter) ResetConfiguration() {
// SetTime sets the time
func (gc *GQGMCCounter) SetTime(t time.Time) {
//command: <SETDATETIME[YYMMDDHHMMSS]>>
//Firmware supported: GMC-280, GMC-300 Re.3.00 or later
cmd := make([]byte, 13)
var timeCmds = []struct {
cmd string
......@@ -297,6 +303,29 @@ func (gc *GQGMCCounter) SetTime(t time.Time) {
}
}
// GetTime gets the time
func (gc *GQGMCCounter) GetTime() (time.Time, error) {
b, err := gc.communicate(cmdGetTime, 7)
if err != nil {
return time.Unix(0, 0), err
}
t := time.Date(int(b[0])+2000, time.Month(b[1]), int(b[2]),
int(b[3]), int(b[4]), int(b[5]), 0, nil)
return t, nil
}
// FactoryReset does a factory reset
func (gc *GQGMCCounter) FactoryReset() {
gc.sendCmd(cmdFactoryReset)
return
}
// Reboot reboots the device
func (gc *GQGMCCounter) Reboot() {
gc.sendCmd(cmdReboot)
return
}
func (gc *GQGMCCounter) communicate(cmd string, length uint32) ([]byte, error) {
gc.Clear()
if len(cmd) > 0 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment