Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
go-daq
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
MIM
go-daq
Commits
9f79596d
Commit
9f79596d
authored
5 years ago
by
Sebastien Binet
Browse files
Options
Downloads
Patches
Plain Diff
dif: streamline Encoder/Decoder documentation
parent
a0056341
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dif/const.go
+20
-0
20 additions, 0 deletions
dif/const.go
dif/decoder.go
+5
-18
5 additions, 18 deletions
dif/decoder.go
dif/encoder.go
+6
-0
6 additions, 0 deletions
dif/encoder.go
with
31 additions
and
18 deletions
dif/const.go
0 → 100644
+
20
−
0
View file @
9f79596d
// Copyright 2020 The go-lpc Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
dif
const
(
// scHeader = 0xb1 // slow-control header marker
// scTrailer = 0xa1 // slow-control trailer marker
gbHeader
=
0xb0
// global header marker
gbHeaderB
=
0xbb
// global header marker (0xBB variant)
gbTrailer
=
0xa0
// global trailer marker
frHeader
=
0xb4
// frame header marker
frTrailer
=
0xa3
// frame trailer marker
anHeader
=
0xc4
// analog frame header marker
incFrame
=
0xc3
// incomplete frame marker
)
This diff is collapsed.
Click to expand it.
dif/decoder.go
+
5
−
18
View file @
9f79596d
...
...
@@ -12,23 +12,8 @@ import (
"golang.org/x/xerrors"
)
const
(
// scHeader = 0xb1 // slow-control header marker
// scTrailer = 0xa1 // slow-control trailer marker
gbHeader
=
0xb0
// global header marker
gbHeaderB
=
0xbb
// global header marker (0xBB variant)
gbTrailer
=
0xa0
// global trailer marker
frHeader
=
0xb4
// frame header marker
frTrailer
=
0xa3
// frame trailer marker
anHeader
=
0xc4
// analog frame header marker
incFrame
=
0xc3
// incomplete frame marker
)
// Decoder reads (and validates) data from an underlying data source.
// Decoder computes CRC-16 checksums on the fly, during the
// Decoder reads and decodes DIF data from an input stream.
// Decoder computes the CRC-16 checksums on the fly, during the
// acquisition of DIF Frames.
type
Decoder
struct
{
r
io
.
Reader
...
...
@@ -39,7 +24,7 @@ type Decoder struct {
crc
crc16
.
Hash16
}
// NewDecoder
c
re
ates a d
ecoder that reads
and validates data
from r.
// NewDecoder re
turns a new D
ecoder that reads from r.
func
NewDecoder
(
difID
uint8
,
r
io
.
Reader
)
*
Decoder
{
return
&
Decoder
{
r
:
r
,
...
...
@@ -57,6 +42,8 @@ func (dec *Decoder) reset() {
dec
.
crc
.
Reset
()
}
// Decode reads the next DIF data from its input stream and stores it
// in the value pointed by dif.
func
(
dec
*
Decoder
)
Decode
(
dif
*
DIF
)
error
{
dec
.
reset
()
...
...
This diff is collapsed.
Click to expand it.
dif/encoder.go
+
6
−
0
View file @
9f79596d
...
...
@@ -12,6 +12,9 @@ import (
"golang.org/x/xerrors"
)
// Encoder writes DIF data to an output stream.
// Encoder computes the CRC-16 checksum on the fly and appends it
// at the end of the stream.
type
Encoder
struct
{
w
io
.
Writer
buf
[]
byte
...
...
@@ -19,6 +22,7 @@ type Encoder struct {
crc
crc16
.
Hash16
}
// NewEncoder returns a new Encoder that writes to w.
func
NewEncoder
(
w
io
.
Writer
)
*
Encoder
{
return
&
Encoder
{
w
:
w
,
...
...
@@ -35,6 +39,8 @@ func (enc *Encoder) reset() {
enc
.
crc
.
Reset
()
}
// Encode writes the DIF data to the stream, computes the corresponding
// CRC-16 checksum on the fly and appends it to the stream.
func
(
enc
*
Encoder
)
Encode
(
dif
*
DIF
)
error
{
if
dif
==
nil
{
return
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