Select Git revision
-
Kevin Lyda authoredKevin Lyda authored
gqgmc.go 13.05 KiB
//
// gqgmc.go
// Copyright (C) 2017 kevin <kevin@phrye.com>
//
// Distributed under terms of the GPL license.
//
package geiger
import (
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"strconv"
"sync"
"time"
"github.com/go-restruct/restruct"
"github.com/tarm/serial"
)
// The Ideal and Low voltage threshholds
const (
VoltageIdeal = 98
VoltageTooLow = 75
)
const (
cmdGetSerial = "<GETSERIAL>>" // GMC-280, GMC-300 Re.2.11
cmdGetVersion = "<GETVER>>" // GMC-280, GMC-300 Re.2.0x, Re.2.10
cmdGetVoltage = "<GETVOLT>>" // GMC-280, GMC-300 Re.2.0x, Re.2.10
cmdGetCPM = "<GETCPM>>" // GMC-280, GMC-300 Re.2.0x, Re.2.10
cmdGetCPS = "<GETCPS>>" // GMC-280, GMC-300 Re.2.0x, Re.2.10
cmdGetCfg = "<GETCFG>>" // GMC-280, GMC-300 Re.2.10
cmdEraseCfg = "<ECFG>>" // GMC-280, GMC-300 Re.2.10
cmdUpdateCfg = "<CFGUPDATE>>" // GMC-280, GMC-300 Re.2.20
cmdTurnOnCPS = "<HEARTBEAT1>>" // GMC-280, GMC-300 Re.2.10
cmdTurnOffCPS = "<HEARTBEAT0>>" // Re.2.10
cmdTurnOffPwr = "<POWEROFF>>" // GMC-280, GMC-300 Re.2.11
cmdTurnOnPwr = "<POWERON>>" // GMC-280, GMC-300 Re.3.10
cmdFactoryReset = "<FACTORYRESET>>" // GMC-280, GMC-300 Re.3.00
cmdReboot = "<REBOOT>>" // GMC-280, GMC-300 Re.3.00
cmdGetTime = "<GETDATETIME>>" // GMC-280, GMC-300 Re.3.00
cmdGetTemp = "<GETTEMP>>" // GMC-320 Re.3.01
cmdGetGyro = "<GETGYRO>>" // GMC-320 Re.3.01
)
var (
mod280n300 = []string{"GMC-280", "GMC-300"}
mod320 = []string{"GMC-320"}
)
// GQGMCCounter is a GQ GMC Counter
type GQGMCCounter struct {
port *serial.Port
config *serial.Config
version,
model,
serial string
mutex *sync.Mutex
}
// DevConfig is the gcgmc config block.
type DevConfig struct {
PowerOnOff int8 `struct:"int8"`
AlarmOnOff int8 `struct:"int8"`
SpeakerOnOff int8 `struct:"int8"`
GraphicModeOnOff int8 `struct:"int8"`
BackLightTimeoutSeconds int8 `struct:"int8"`