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
ffdcc4b2
Commit
ffdcc4b2
authored
5 years ago
by
Sebastien Binet
Browse files
Options
Downloads
Patches
Plain Diff
dif: fixup CRC-16 computation
parent
cde01346
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/decoder.go
+1
-1
1 addition, 1 deletion
dif/decoder.go
dif/encoder.go
+2
-1
2 additions, 1 deletion
dif/encoder.go
dif/rw_test.go
+5
-5
5 additions, 5 deletions
dif/rw_test.go
with
8 additions
and
7 deletions
dif/decoder.go
+
1
−
1
View file @
ffdcc4b2
...
...
@@ -103,6 +103,7 @@ loop:
dec
.
dif
,
dec
.
err
,
)
}
dec
.
crcU8
(
v
)
switch
v
{
default
:
...
...
@@ -113,7 +114,6 @@ loop:
return
xerrors
.
Errorf
(
"dif: DIF 0x%x contains an analog frame"
,
dec
.
dif
)
case
frHeader
:
dec
.
crcU8
(
v
)
frameLoop
:
for
{
v
:=
dec
.
readU8
()
...
...
This diff is collapsed.
Click to expand it.
dif/encoder.go
+
2
−
1
View file @
ffdcc4b2
...
...
@@ -68,8 +68,9 @@ func (enc *Encoder) Encode(dif *DIF) error {
enc
.
write
(
frame
.
Data
[
:
])
}
enc
.
writeU8
(
frTrailer
)
crc
:=
enc
.
crc
.
Sum16
()
// gb-trailer not part of CRC-16
enc
.
writeU8
(
gbTrailer
)
crc
:=
enc
.
crc
.
Sum16
()
enc
.
writeU16
(
crc
)
return
enc
.
err
...
...
This diff is collapsed.
Click to expand it.
dif/rw_test.go
+
5
−
5
View file @
ffdcc4b2
...
...
@@ -159,7 +159,7 @@ func TestDecoder(t *testing.T) {
frTrailer
,
gbTrailer
,
0x
4c
,
0x
1
a
,
// CRC-16
0x
26
,
0xa
2
,
// CRC-16
},
},
{
...
...
@@ -187,7 +187,7 @@ func TestDecoder(t *testing.T) {
frTrailer
,
gbTrailer
,
0x
4c
,
0x
1
a
,
// CRC-16
0x
26
,
0xa
2
,
// CRC-16
gbHeader
,
difID
,
...
...
@@ -210,7 +210,7 @@ func TestDecoder(t *testing.T) {
frTrailer
,
gbTrailer
,
0x
fa
,
0x
67
,
// CRC-16
0x
9c
,
0x
bf
,
// CRC-16
},
},
{
...
...
@@ -239,7 +239,7 @@ func TestDecoder(t *testing.T) {
frTrailer
,
gbTrailer
,
0x
52
,
0x
3f
,
// CRC-16
0x
f0
,
0x
5d
,
// CRC-16
},
},
{
...
...
@@ -510,7 +510,7 @@ func TestDecoder(t *testing.T) {
gbTrailer
,
0xb5
,
0xff
,
// CRC-16
},
want
:
xerrors
.
Errorf
(
"dif: DIF 0x%x inconsistent CRC: recv=0xb5ff comp=0x
4c1a
"
,
difID
),
want
:
xerrors
.
Errorf
(
"dif: DIF 0x%x inconsistent CRC: recv=0xb5ff comp=0x
26a2
"
,
difID
),
},
}
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
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