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

Further.

parent da2b152e
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -106,13 +106,13 @@ const ( ...@@ -106,13 +106,13 @@ const (
cmdGetSerial = "<GETSERIAL>>" cmdGetSerial = "<GETSERIAL>>"
cmdGetVersion = "<GETVER>>" cmdGetVersion = "<GETVER>>"
cmdGetVoltage = "<GETVOLT>>" cmdGetVoltage = "<GETVOLT>>"
cmdGetCpm = "<GETCPM>>" cmdGetCPM = "<GETCPM>>"
cmdGetCps = "<GETCPS>>" cmdGetCPS = "<GETCPS>>"
cmdGetCfg = "<GETCFG>>" cmdGetCfg = "<GETCFG>>"
cmdEraseCfg = "<ECFG>>" cmdEraseCfg = "<ECFG>>"
cmdUpdateCfg = "<CFGUPDATE>>" cmdUpdateCfg = "<CFGUPDATE>>"
cmdTurnOnCps = "<HEARTBEAT1>>" cmdTurnOnCPS = "<HEARTBEAT1>>"
cmdTurnOffCps = "<HEARTBEAT0>>" cmdTurnOffCPS = "<HEARTBEAT0>>"
cmdTurnOffPwr = "<POWEROFF>>" cmdTurnOffPwr = "<POWEROFF>>"
) )
...@@ -192,14 +192,13 @@ func (gc *GQGMCCounter) SerialNum() (string, error) { ...@@ -192,14 +192,13 @@ func (gc *GQGMCCounter) SerialNum() (string, error) {
// GetCPM returns CPM // GetCPM returns CPM
func (gc *GQGMCCounter) GetCPM() (uint16, error) { func (gc *GQGMCCounter) GetCPM() (uint16, error) {
//uint32_t cpmsize = 2; // 2 bytes of returned data buf, err := gc.communicate([]byte(cmdGetCPM), 2)
//communicate(get_cpm_cmd, cpm_char, cpmsize); if err != nil {
// 1st byte is MSB, but note that upper two bits are reserved bits. return 0, err
// Note that shifting and bitmasking performed in uP register, so }
// endianess is irrevelant. cpm := ((uint16(buf[0]) << 8) & 0x3f00)
//cpm_int |= ((uint16_t(cpm_char[0]) << 8) & 0x3f00); cpm |= (uint16(buf[1]) & 0x00ff)
//cpm_int |= (uint16_t(cpm_char[1]) & 0x00ff); return cpm, nil
return 0, nil
} }
// GetCPS returns CPS // GetCPS returns CPS
...@@ -344,19 +343,22 @@ func (gc *GQGMCCounter) SetTime(time string) { ...@@ -344,19 +343,22 @@ func (gc *GQGMCCounter) SetTime(time string) {
} }
func (gc *GQGMCCounter) communicate(cmd []byte, length uint32) ([]byte, error) { func (gc *GQGMCCounter) communicate(cmd []byte, length uint32) ([]byte, error) {
//clearUSB(); gc.Clear()
//if (cmd.size() > 0) sendCmd(cmd); if len(cmd) > 0 {
//if (retbytes > 0) readCmdReturn(retdata, retbytes); gc.sendCmd(cmd)
}
if length != 0 {
return gc.readCmd(length)
}
return nil, nil return nil, nil
} }
func (gc *GQGMCCounter) sendCmd(cmd []byte) { func (gc *GQGMCCounter) sendCmd(cmd []byte) {
// The port write thing
gc.port.Write(cmd) gc.port.Write(cmd)
return return
} }
func (gc *GQGMCCounter) readCmdReturn(length uint32) ([]byte, error) { func (gc *GQGMCCounter) readCmd(length uint32) ([]byte, error) {
buf := make([]byte, length) buf := make([]byte, length)
n, err := gc.port.Read(buf) n, err := gc.port.Read(buf)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment