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
04cbaf04
There was a problem fetching the pipeline summary.
Commit
04cbaf04
authored
Jan 31, 2017
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Add some model checks.
parent
e87d2d8d
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/gqgmc/main.go
+4
-1
4 additions, 1 deletion
cmd/gqgmc/main.go
devices/geiger/gqgmc.go
+43
-4
43 additions, 4 deletions
devices/geiger/gqgmc.go
with
47 additions
and
5 deletions
cmd/gqgmc/main.go
+
4
−
1
View file @
04cbaf04
...
...
@@ -9,8 +9,9 @@ package main
import
(
"fmt"
"gitlab.com/lyda/gqgmc/devices/geiger"
"time"
"gitlab.com/lyda/gqgmc/devices/geiger"
)
func
main
()
{
...
...
@@ -32,6 +33,8 @@ func main() {
return
}
gc
.
SetTime
(
time
.
Now
())
t
,
err
=
gc
.
GetTime
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed: '%s'
\n
"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
devices/geiger/gqgmc.go
+
43
−
4
View file @
04cbaf04
...
...
@@ -203,9 +203,19 @@ func (gc *GQGMCCounter) SetConfiguration() {
// SetTime sets the time
func
(
gc
*
GQGMCCounter
)
SetTime
(
t
time
.
Time
)
{
//command: <SETDATETIME[YYMMDDHHMMSS]>>
//Firmware supported: GMC-280, GMC-300 Re.3.00 or later
if
!
gc
.
supportedModels
([]
string
{
"GMC-280"
,
"GMC-300"
})
{
return
}
if
gc
.
versionLT
(
"Re 2.23"
)
{
return
}
if
gc
.
versionLT
(
"Re 3.30"
)
{
gc
.
setTimeParts
(
t
)
}
gc
.
setTimeAll
(
t
)
}
func
(
gc
*
GQGMCCounter
)
setTimeParts
(
t
time
.
Time
)
{
cmd
:=
make
([]
byte
,
13
)
var
timeCmds
=
[]
struct
{
cmd
string
...
...
@@ -223,11 +233,27 @@ func (gc *GQGMCCounter) SetTime(t time.Time) {
copy
(
cmd
[
:
],
c
.
cmd
)
cmd
[
10
]
=
uint8
(
c
.
unit
)
copy
(
cmd
[
11
:
],
">>"
)
gc
.
port
.
Write
(
cmd
)
gc
.
readCmd
(
1
)
fmt
.
Printf
(
"%s: %+v
\n
"
,
c
.
cmd
,
cmd
)
//gc.port.Write(cmd)
//gc.readCmd(1)
}
}
func
(
gc
*
GQGMCCounter
)
setTimeAll
(
t
time
.
Time
)
{
cmd
:=
make
([]
byte
,
13
)
copy
(
cmd
[
:
],
"<SETDATETIME"
)
cmd
[
12
]
=
uint8
(
t
.
Year
())
cmd
[
13
]
=
uint8
(
int
(
t
.
Month
()))
cmd
[
14
]
=
uint8
(
t
.
Day
())
cmd
[
15
]
=
uint8
(
t
.
Hour
())
cmd
[
16
]
=
uint8
(
t
.
Minute
())
cmd
[
17
]
=
uint8
(
t
.
Second
())
copy
(
cmd
[
18
:
],
">>"
)
fmt
.
Printf
(
"setTimeAll: %+v
\n
"
,
cmd
)
//gc.port.Write(cmd)
//gc.readCmd(1)
}
// GetTime gets the time
func
(
gc
*
GQGMCCounter
)
GetTime
()
(
time
.
Time
,
error
)
{
b
,
err
:=
gc
.
communicate
(
cmdGetTime
,
7
)
...
...
@@ -284,6 +310,19 @@ func (gc *GQGMCCounter) Reboot() {
return
}
func
(
gc
*
GQGMCCounter
)
supportedModels
(
models
[]
string
)
bool
{
for
_
,
model
:=
range
models
{
if
model
==
gc
.
model
{
return
true
}
}
return
false
}
func
(
gc
*
GQGMCCounter
)
versionLT
(
version
string
)
bool
{
return
gc
.
version
<
version
}
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
string
,
length
uint32
)
([]
byte
,
error
)
{
gc
.
Clear
()
if
len
(
cmd
)
>
0
{
...
...
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