Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kevin Lyda
gqgmc
Commits
24382813
Commit
24382813
authored
Jan 31, 2017
by
Kevin Lyda
💬
Browse files
Rework version.
parent
b5e0ca3f
Pipeline
#1209
passed with stage
in 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cmd/gqgmc/main.go
View file @
24382813
...
...
@@ -20,7 +20,6 @@ func main() {
volts
int16
ser
string
err
error
ver
string
t
time
.
Time
)
...
...
@@ -54,12 +53,9 @@ func main() {
}
fmt
.
Printf
(
"CPS: %d
\n
"
,
cps
)
ver
,
err
=
gc
.
Version
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed: '%s'
\n
"
,
err
)
return
}
fmt
.
Printf
(
"Version: %s
\n
"
,
ver
)
fmt
.
Printf
(
"Version: %s
\n
"
,
gc
.
Version
())
fmt
.
Printf
(
"Short Version: %s
\n
"
,
gc
.
Ver
())
fmt
.
Printf
(
"Model: %s
\n
"
,
gc
.
Model
())
ser
,
err
=
gc
.
SerialNum
()
if
err
!=
nil
{
...
...
devices/geiger/geiger.go
View file @
24382813
...
...
@@ -21,7 +21,9 @@ func New(c Config) (Counter, error) {
// Counter is an interface for Geiger Counters
type
Counter
interface
{
Clear
()
error
Version
()
(
string
,
error
)
Model
()
string
Version
()
string
Ver
()
string
SerialNum
()
(
string
,
error
)
GetCPM
()
(
uint16
,
error
)
GetCPS
()
(
uint16
,
error
)
...
...
devices/geiger/gqgmc.go
View file @
24382813
...
...
@@ -123,21 +123,32 @@ const (
type
GQGMCCounter
struct
{
port
*
serial
.
Port
config
*
serial
.
Config
version
,
shortVer
,
model
string
}
// NewGQGMC creates a new GQGMC Counter instance
func
NewGQGMC
(
c
Config
)
(
*
GQGMCCounter
,
error
)
{
cfg
:=
serial
.
Config
{
var
gc
GQGMCCounter
var
v
[]
byte
gc
.
config
=
&
serial
.
Config
{
Name
:
c
.
Device
,
Baud
:
57600
,
ReadTimeout
:
500
*
time
.
Millisecond
,
}
p
,
err
:=
serial
.
OpenPort
(
&
cf
g
)
p
,
err
:=
serial
.
OpenPort
(
gc
.
confi
g
)
if
err
!=
nil
{
return
nil
,
err
}
gc
.
port
=
p
v
,
err
=
gc
.
communicate
(
cmdGetVersion
,
14
)
gc
.
model
=
string
(
v
[
:
6
])
gc
.
version
=
string
(
v
[
7
:
])
gc
.
shortVer
=
string
(
v
[
10
:
])
//getConfigurationData()
return
&
GQGMCCounter
{
port
:
p
,
config
:
&
cfg
}
,
nil
return
&
gc
,
nil
}
// Clear clears out any remaining data
...
...
@@ -153,9 +164,18 @@ func (gc *GQGMCCounter) Clear() error {
}
// Version gets the version of the device
func
(
gc
*
GQGMCCounter
)
Version
()
(
string
,
error
)
{
ver
,
err
:=
gc
.
communicate
(
cmdGetVersion
,
14
)
return
string
(
ver
),
err
func
(
gc
*
GQGMCCounter
)
Version
()
string
{
return
gc
.
version
}
// Ver gets the short version of the device
func
(
gc
*
GQGMCCounter
)
Ver
()
string
{
return
gc
.
shortVer
}
// Model gets the model of the device
func
(
gc
*
GQGMCCounter
)
Model
()
string
{
return
gc
.
model
}
// SerialNum gets the serial number of the device
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment