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
c1cdc990
There was a problem fetching the pipeline summary.
Commit
c1cdc990
authored
Jan 30, 2017
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
More implemented; tried.
parent
a7ce96ee
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
+25
-0
25 additions, 0 deletions
cmd/gqgmc/main.go
devices/geiger/geiger.go
+1
-1
1 addition, 1 deletion
devices/geiger/geiger.go
devices/geiger/gqgmc.go
+32
-41
32 additions, 41 deletions
devices/geiger/gqgmc.go
with
58 additions
and
42 deletions
cmd/gqgmc/main.go
+
25
−
0
View file @
c1cdc990
...
...
@@ -16,7 +16,10 @@ func main() {
var
(
gc
geiger
.
Counter
cps
,
cpm
uint16
volts
int16
ser
string
err
error
ver
string
)
gc
,
err
=
geiger
.
New
(
geiger
.
Config
{
...
...
@@ -41,4 +44,26 @@ func main() {
return
}
fmt
.
Printf
(
"CPS: %d
\n
"
,
cps
)
ver
,
err
=
gc
.
Version
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to connect to geiger counter: '%s'
\n
"
,
err
)
return
}
fmt
.
Printf
(
"Version: %s
\n
"
,
ver
)
ser
,
err
=
gc
.
SerialNum
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to connect to geiger counter: '%s'
\n
"
,
err
)
return
}
fmt
.
Printf
(
"Version: %s
\n
"
,
ser
)
volts
,
err
=
gc
.
Volts
()
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to connect to geiger counter: '%s'
\n
"
,
err
)
return
}
fmt
.
Printf
(
"Version: %d
\n
"
,
volts
)
}
This diff is collapsed.
Click to expand it.
devices/geiger/geiger.go
+
1
−
1
View file @
c1cdc990
...
...
@@ -23,7 +23,7 @@ type Counter interface {
SerialNum
()
(
string
,
error
)
GetCPM
()
(
uint16
,
error
)
GetCPS
()
(
uint16
,
error
)
Get
Volt
age
()
(
int16
,
error
)
Volt
s
()
(
int16
,
error
)
GetHistoryData
()
TurnOnCPS
()
error
TurnOffCPS
()
error
...
...
This diff is collapsed.
Click to expand it.
devices/geiger/gqgmc.go
+
32
−
41
View file @
c1cdc990
...
...
@@ -158,7 +158,6 @@ func NewGQGMC(c Config) (*GQGMCCounter, error) {
if
err
!=
nil
{
return
nil
,
err
}
//vers := getVersion()
//getConfigurationData()
return
&
GQGMCCounter
{
port
:
p
,
config
:
&
cfg
},
nil
}
...
...
@@ -172,26 +171,25 @@ func (gc *GQGMCCounter) Clear() error {
// Version gets the version of the device
func
(
gc
*
GQGMCCounter
)
Version
()
(
string
,
error
)
{
//communicate(get_version_cmd, version, versize);
// use cmdGetVersion. Returns 14 byte string.
return
""
,
nil
ver
,
err
:=
gc
.
communicate
(
cmdGetVersion
,
14
)
return
string
(
ver
),
err
}
// SerialNum gets the serial number of the device
func
(
gc
*
GQGMCCounter
)
SerialNum
()
(
string
,
error
)
{
//communicate(get_serial_cmd, serial_number, sernumsize);
// use cmdGetSerial. Returns 7 bytes.
// Turn each 4 bits into corresponging hex char.
bs
:=
[]
byte
{
0
,
0x30
,
0
,
0xE3
,
0x4A
,
0x35
,
0x1A
}
for
_
,
b
:=
range
bs
{
fmt
.
Printf
(
"%02X"
,
b
)
serStr
:=
""
ser
,
err
:=
gc
.
communicate
(
cmdGetSerial
,
7
)
if
err
!=
nil
{
for
_
,
b
:=
range
ser
{
serStr
+=
fmt
.
Sprintf
(
"%02X"
,
b
)
}
}
fmt
.
Println
(
""
)
return
""
,
nil
return
serStr
,
err
}
func
(
gc
*
GQGMCCounter
)
getReading
(
what
string
)
(
uint16
,
error
)
{
buf
,
err
:=
gc
.
communicate
(
[]
byte
(
what
)
,
2
)
buf
,
err
:=
gc
.
communicate
(
what
,
2
)
if
err
!=
nil
{
return
0
,
err
}
...
...
@@ -210,8 +208,8 @@ func (gc *GQGMCCounter) GetCPS() (uint16, error) {
return
gc
.
getReading
(
cmdGetCPS
)
}
//
Get
Volt
age
returns current battery voltage
func
(
gc
*
GQGMCCounter
)
Get
Volt
age
()
(
int16
,
error
)
{
// Volt
s
returns current battery voltage
func
(
gc
*
GQGMCCounter
)
Volt
s
()
(
int16
,
error
)
{
// Do this differently - for 9.6 return 96. And if not supported,
// Return -1.
// Public method to read voltage value of battery. The GQ GMC returns
...
...
@@ -221,15 +219,11 @@ func (gc *GQGMCCounter) GetVoltage() (int16, error) {
// expect to see a value higher than 100. The command is get_voltage_cmd
// (see GQ GMC COMMANDS above). If the voltage falls below 7.5V, GQ LLC
// says the geiger counter cannot be expected to operate properly.
//func (gc *GQGMCCounter) getBatteryVoltage()
//uint32_t voltsize = 1; // one byte of returned data
// Issue command to get battery voltage and read returned data.
//communicate(get_voltage_cmd, voltage_char, voltsize);
// If read of returned data succeeded, convert raw data to float,
//int32_t voltage_int = int16_t(voltage_char[0]);
//voltage = float(voltage_int) / 10.0;
return
0
,
nil
volts
,
err
:=
gc
.
communicate
(
cmdGetVoltage
,
1
)
if
err
!=
nil
{
return
0
,
err
}
return
int16
(
volts
[
0
]),
err
}
// GetHistoryData Should return history data but is unimplemented for now
...
...
@@ -253,34 +247,31 @@ func (gc *GQGMCCounter) TurnOnCPS() error {
// separate command. The command is turn_on_cps_cmd
// (see GQ GMC COMMANDS above). The returned data is always two
// bytes so that samples > 255 can be reported (even though unlikely).
//sendCmd(turn_on_cps_cmd);
// There is no pass/fail return from GQ GMC
gc
.
sendCmd
(
cmdTurnOnCPS
)
return
nil
}
// TurnOffCPS turns off CPS collection
func
(
gc
*
GQGMCCounter
)
TurnOffCPS
()
error
{
//
sendCmd(
turn_off_cps_cmd);
//call
Clear()
gc
.
sendCmd
(
cmdTurnOffCPS
)
gc
.
Clear
()
return
nil
}
// GetAutoCPS gets a reading once auto CPS is turned on
func
(
gc
*
GQGMCCounter
)
GetAutoCPS
()
(
uint16
,
error
)
{
//uint32_t cpssize = 2; // 2 bytes of returned data
//read-from-port(cps_char, cpssize);
// 1st byte is MSB, but note that upper two bits are reserved bits.
// Note that shifting and bitmasking performed in uP register, so
// endianess is irrevelant.
//cps_int |= ((uint16_t(cps_char[0]) << 8) & 0x3f00);
//cps_int |= (uint16_t(cps_char[1]) & 0x00ff);
return
0
,
nil
buf
,
err
:=
gc
.
readCmd
(
2
)
if
err
!=
nil
{
return
0
,
err
}
cps
:=
((
uint16
(
buf
[
0
])
<<
8
)
&
0x3f00
)
cps
|=
(
uint16
(
buf
[
1
])
&
0x00ff
)
return
cps
,
nil
}
// TurnOffPower turns the device off
func
(
gc
*
GQGMCCounter
)
TurnOffPower
()
{
//sendCmd(turn_off_pwr_cmd)
// Note that power off cannot fail because the GQ GMC returns nothing.
gc
.
sendCmd
(
cmdTurnOffPwr
)
return
}
...
...
@@ -339,7 +330,7 @@ func (gc *GQGMCCounter) SetTime(time string) {
//communicate(setSecondCmd, ret_char, retsize);
}
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
[]
byte
,
length
uint32
)
([]
byte
,
error
)
{
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
string
,
length
uint32
)
([]
byte
,
error
)
{
gc
.
Clear
()
if
len
(
cmd
)
>
0
{
gc
.
sendCmd
(
cmd
)
...
...
@@ -350,8 +341,8 @@ func (gc *GQGMCCounter) communicate(cmd []byte, length uint32) ([]byte, error) {
return
nil
,
nil
}
func
(
gc
*
GQGMCCounter
)
sendCmd
(
cmd
[]
byte
)
{
gc
.
port
.
Write
(
cmd
)
func
(
gc
*
GQGMCCounter
)
sendCmd
(
cmd
string
)
{
gc
.
port
.
Write
(
[]
byte
(
cmd
)
)
return
}
...
...
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