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
68a4c89c
There was a problem fetching the pipeline summary.
Commit
68a4c89c
authored
8 years ago
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Work on GetConfiguration.
parent
ed1aaa1f
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/geiger/gqgmc.go
+27
-16
27 additions, 16 deletions
devices/geiger/gqgmc.go
with
27 additions
and
16 deletions
devices/geiger/gqgmc.go
+
27
−
16
View file @
68a4c89c
...
...
@@ -95,7 +95,7 @@ func (gc *GQGMCCounter) Clear() error {
// Read up to 10 chars until nothing comes back.
// error otherwise.
for
i
:=
0
;
i
<
10
;
i
++
{
if
_
,
err
:=
gc
.
re
adCmd
(
1
);
err
!=
nil
{
if
_
,
err
:=
gc
.
re
cv
(
1
);
err
!=
nil
{
break
}
}
...
...
@@ -169,7 +169,7 @@ func (gc *GQGMCCounter) TurnOnCPS() error {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdTurnOnCPS
)
gc
.
send
(
cmdTurnOnCPS
)
gc
.
mutex
.
Unlock
()
return
nil
}
...
...
@@ -184,7 +184,7 @@ func (gc *GQGMCCounter) TurnOffCPS() error {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdTurnOffCPS
)
gc
.
send
(
cmdTurnOffCPS
)
gc
.
Clear
()
gc
.
mutex
.
Unlock
()
return
nil
...
...
@@ -193,7 +193,7 @@ func (gc *GQGMCCounter) TurnOffCPS() error {
// GetAutoCPS gets a reading once auto CPS is turned on
func
(
gc
*
GQGMCCounter
)
GetAutoCPS
()
(
uint16
,
error
)
{
gc
.
mutex
.
Lock
()
buf
,
err
:=
gc
.
re
adCmd
(
2
)
buf
,
err
:=
gc
.
re
cv
(
2
)
gc
.
mutex
.
Unlock
()
if
err
!=
nil
{
...
...
@@ -214,7 +214,7 @@ func (gc *GQGMCCounter) TurnOnPower() {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdTurnOnPwr
)
gc
.
send
(
cmdTurnOnPwr
)
gc
.
mutex
.
Unlock
()
return
}
...
...
@@ -229,7 +229,7 @@ func (gc *GQGMCCounter) TurnOffPower() {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdTurnOffPwr
)
gc
.
send
(
cmdTurnOffPwr
)
gc
.
mutex
.
Unlock
()
return
}
...
...
@@ -299,7 +299,7 @@ func (gc *GQGMCCounter) setTimeParts(t time.Time) {
copy
(
cmd
[
11
:
],
">>"
)
// Mutex acquired in setTime()
gc
.
port
.
Write
(
cmd
)
gc
.
re
adCmd
(
1
)
gc
.
re
cv
(
1
)
}
}
...
...
@@ -315,7 +315,7 @@ func (gc *GQGMCCounter) setTimeAll(t time.Time) {
copy
(
cmd
[
18
:
],
">>"
)
// Mutex acquired in setTime()
gc
.
port
.
Write
(
cmd
)
gc
.
re
adCmd
(
1
)
gc
.
re
cv
(
1
)
}
// GetTime gets the time
...
...
@@ -393,7 +393,7 @@ func (gc *GQGMCCounter) FactoryReset() {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdFactoryReset
)
gc
.
send
(
cmdFactoryReset
)
gc
.
mutex
.
Unlock
()
return
}
...
...
@@ -408,7 +408,7 @@ func (gc *GQGMCCounter) Reboot() {
}
gc
.
mutex
.
Lock
()
gc
.
send
Cmd
(
cmdReboot
)
gc
.
send
(
cmdReboot
)
gc
.
mutex
.
Unlock
()
return
}
...
...
@@ -426,31 +426,42 @@ func (gc *GQGMCCounter) versionLT(version string) bool {
return
gc
.
version
<
version
}
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
string
,
length
u
int
32
)
([]
byte
,
error
)
{
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
string
,
length
int
)
([]
byte
,
error
)
{
gc
.
mutex
.
Lock
()
defer
gc
.
mutex
.
Unlock
()
gc
.
Clear
()
if
len
(
cmd
)
>
0
{
gc
.
send
Cmd
(
cmd
)
gc
.
send
(
cmd
)
}
if
length
!=
0
{
return
gc
.
re
adCmd
(
length
)
return
gc
.
re
cv
(
length
)
}
return
nil
,
nil
}
func
(
gc
*
GQGMCCounter
)
send
Cmd
(
cmd
string
)
{
func
(
gc
*
GQGMCCounter
)
send
(
cmd
string
)
{
gc
.
port
.
Write
([]
byte
(
cmd
))
return
}
func
(
gc
*
GQGMCCounter
)
re
adCmd
(
length
u
int
32
)
([]
byte
,
error
)
{
func
(
gc
*
GQGMCCounter
)
re
cv
(
length
int
)
([]
byte
,
error
)
{
buf
:=
make
([]
byte
,
length
)
n
,
err
:=
gc
.
port
.
Read
(
buf
)
if
err
!=
nil
{
return
nil
,
err
}
if
uint32
(
n
)
!=
length
{
if
n
!=
length
{
for
i
:=
0
;
i
<
20
;
i
++
{
_
,
err
=
gc
.
port
.
Read
(
buf
[
len
(
buf
)
:
])
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
buf
)
==
length
{
break
}
}
}
if
n
!=
length
{
return
nil
,
fmt
.
Errorf
(
"Short read (got: %d, wanted: %d)"
,
uint32
(
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