Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gqgmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kevin Lyda
gqgmc
Commits
f0262953
There was a problem fetching the pipeline summary.
Commit
f0262953
authored
Feb 1, 2017
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Work on GetConfiguration.
parent
13e4ab24
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/gqgmc/main.go
+4
-1
4 additions, 1 deletion
cmd/gqgmc/main.go
devices/geiger/geiger.go
+2
-2
2 additions, 2 deletions
devices/geiger/geiger.go
devices/geiger/gqgmc.go
+76
-13
76 additions, 13 deletions
devices/geiger/gqgmc.go
with
82 additions
and
16 deletions
cmd/gqgmc/main.go
+
4
−
1
View file @
f0262953
...
...
@@ -17,6 +17,7 @@ import (
func
main
()
{
var
(
gc
geiger
.
Counter
cfg
*
geiger
.
DevConfig
cps
,
cpm
uint16
volts
int16
temp
float64
...
...
@@ -72,9 +73,11 @@ func main() {
fmt
.
Printf
(
"Temp: %g
\n
"
,
temp
)
}
err
=
gc
.
GetConfiguration
()
cfg
,
err
=
gc
.
GetConfiguration
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to get config: '%s'
\n
"
,
err
)
}
else
{
fmt
.
Printf
(
"Cfg: %+v
\n
"
,
cfg
)
}
}
This diff is collapsed.
Click to expand it.
devices/geiger/geiger.go
+
2
−
2
View file @
f0262953
...
...
@@ -27,12 +27,12 @@ type Counter interface {
GetCPM
()
(
uint16
,
error
)
GetCPS
()
(
uint16
,
error
)
Volts
()
(
int16
,
error
)
GetHistory
Data
()
GetHistory
()
TurnOnCPS
()
error
TurnOffCPS
()
error
GetAutoCPS
()
(
uint16
,
error
)
TurnOffPower
()
GetConfiguration
()
error
GetConfiguration
()
(
*
DevConfig
,
error
)
SetConfiguration
()
SetTime
(
time
.
Time
)
GetTime
()
(
time
.
Time
,
error
)
...
...
This diff is collapsed.
Click to expand it.
devices/geiger/gqgmc.go
+
76
−
13
View file @
f0262953
...
...
@@ -8,6 +8,7 @@
package
geiger
import
(
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
...
...
@@ -15,6 +16,7 @@ import (
"sync"
"time"
"github.com/go-restruct/restruct"
"github.com/tarm/serial"
)
...
...
@@ -59,6 +61,66 @@ type GQGMCCounter struct {
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"`
IdleTitleDisplayMode
int8
`struct:"int8"`
AlarmCPMValue
int16
`struct:"int16,big"`
CalibrationCPMHiByte0
byte
`struct:"byte"`
CalibrationCPMLoByte0
byte
`struct:"byte"`
CalibrationSvUcByte3p0
byte
`struct:"byte"`
CalibrationSvUcByte2p0
byte
`struct:"byte"`
CalibrationSvUcByte1p0
byte
`struct:"byte"`
CalibrationSvUcByte0p0
byte
`struct:"byte"`
CalibrationCPMHiByte1
byte
`struct:"byte"`
CalibrationCPMLoByte1
byte
`struct:"byte"`
CalibrationSvUcByte3p1
byte
`struct:"byte"`
CalibrationSvUcByte2p1
byte
`struct:"byte"`
CalibrationSvUcByte1p1
byte
`struct:"byte"`
CalibrationSvUcByte0p1
byte
`struct:"byte"`
CalibrationCPMHiByte2
byte
`struct:"byte"`
CalibrationCPMLoByte2
byte
`struct:"byte"`
CalibrationSvUcByte3p2
byte
`struct:"byte"`
CalibrationSvUcByte2p2
byte
`struct:"byte"`
CalibrationSvUcByte1p2
byte
`struct:"byte"`
CalibrationSvUcByte0p2
byte
`struct:"byte"`
IdleDisplayMode
byte
`struct:"byte"`
AlarmValueuSvByte3
byte
`struct:"byte"`
AlarmValueuSvByte2
byte
`struct:"byte"`
AlarmValueuSvByte1
byte
`struct:"byte"`
AlarmValueuSvByte0
byte
`struct:"byte"`
AlarmType
byte
`struct:"byte"`
SaveDataType
byte
`struct:"byte"`
SwivelDisplay
byte
`struct:"byte"`
ZoomByte3
byte
`struct:"byte"`
ZoomByte2
byte
`struct:"byte"`
ZoomByte1
byte
`struct:"byte"`
ZoomByte0
byte
`struct:"byte"`
SPIDataSaveAddress2
byte
`struct:"byte"`
SPIDataSaveAddress1
byte
`struct:"byte"`
SPIDataSaveAddress0
byte
`struct:"byte"`
SPIDataReadAddress2
byte
`struct:"byte"`
SPIDataReadAddress1
byte
`struct:"byte"`
SPIDataReadAddress0
byte
`struct:"byte"`
PowerSavingMode
int8
`struct:"int8"`
SensitivityMode
int8
`struct:"int8"`
CounterDelay
int16
`struct:"int16,big"`
VoltageOffset
int8
`struct:"int8"`
MaxCPM
int16
`struct:"int16,big"`
SensitivityAutoModeThreshold
int8
`struct:"int8"`
SaveDateTimeStamp6
byte
`struct:"byte"`
SaveDateTimeStamp5
byte
`struct:"byte"`
SaveDateTimeStamp4
byte
`struct:"byte"`
SaveDateTimeStamp3
byte
`struct:"byte"`
SaveDateTimeStamp2
byte
`struct:"byte"`
SaveDateTimeStamp1
byte
`struct:"byte"`
MaximumBytes
byte
`struct:"byte"`
}
// NewGQGMC creates a new GQGMC Counter instance
func
NewGQGMC
(
c
Config
)
(
*
GQGMCCounter
,
error
)
{
var
gc
GQGMCCounter
...
...
@@ -86,7 +148,7 @@ func NewGQGMC(c Config) (*GQGMCCounter, error) {
gc
.
serial
=
hex
.
EncodeToString
(
buf
)
}
}
//getConfiguration
Data
()
//getConfiguration()
return
&
gc
,
nil
}
...
...
@@ -153,8 +215,8 @@ func (gc *GQGMCCounter) Volts() (int16, error) {
return
int16
(
volts
[
0
]),
err
}
// GetHistory
Data
Should return history data but is unimplemented for now
func
(
gc
*
GQGMCCounter
)
GetHistory
Data
()
{
// GetHistory Should return history data but is unimplemented for now
func
(
gc
*
GQGMCCounter
)
GetHistory
()
{
// It's not recommended to use this so blank for now.
return
}
...
...
@@ -235,20 +297,22 @@ func (gc *GQGMCCounter) TurnOffPower() {
}
// GetConfiguration reads configuration data
func
(
gc
*
GQGMCCounter
)
GetConfiguration
()
error
{
func
(
gc
*
GQGMCCounter
)
GetConfiguration
()
(
*
DevConfig
,
error
)
{
if
!
gc
.
supportedModels
(
mod280n300
)
{
return
errors
.
New
(
"Unsupported Model"
)
return
nil
,
errors
.
New
(
"Unsupported Model"
)
}
if
gc
.
versionLT
(
"Re 2.10"
)
{
return
errors
.
New
(
"Unsupported version"
)
return
nil
,
errors
.
New
(
"Unsupported version"
)
}
cfg
,
err
:=
gc
.
communicate
(
cmdGetCfg
,
256
)
data
,
err
:=
gc
.
communicate
(
cmdGetCfg
,
256
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
fmt
.
Printf
(
"Configuration: %+v
\n
"
,
cfg
)
return
nil
var
cfg
DevConfig
restruct
.
Unpack
(
data
[
:
58
],
binary
.
BigEndian
,
&
cfg
)
fmt
.
Printf
(
"Configuration: %+v
\n
"
,
data
)
return
&
cfg
,
nil
}
// SetConfiguration writes configuration data
...
...
@@ -452,8 +516,9 @@ func (gc *GQGMCCounter) recv(length int) ([]byte, error) {
}
read
:=
n
if
n
!=
length
{
// Handle the case where we couldn't read it all.
// Really only happens for length > 32.
for
i
:=
0
;
i
<
20
;
i
++
{
fmt
.
Printf
(
"%d(%d) "
,
n
,
read
)
n
,
err
=
gc
.
port
.
Read
(
buf
[
read
:
])
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -463,10 +528,8 @@ func (gc *GQGMCCounter) recv(length int) ([]byte, error) {
break
}
}
fmt
.
Printf
(
"%d(%d)
\n
"
,
n
,
read
)
}
if
read
!=
length
{
fmt
.
Printf
(
"Short read: %+v
\n
"
,
buf
)
return
nil
,
fmt
.
Errorf
(
"Short read (got: %d, wanted: %d)"
,
n
,
length
)
}
return
buf
,
nil
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment