Skip to content

Commit

Permalink
docs: update usage.md (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Apr 16, 2024
1 parent a4c820b commit 9becca6
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ func main() {
Example:

```go
al := filedef.NewListener()
lis := filedef.NewListener()
defer lis.Close()
dec := decoder.New(f,
decoder.WithMesgListener(al),
decoder.WithMesgListener(lis),
)
```

Expand All @@ -401,7 +403,7 @@ func main() {
Example:

```go
conv := fitcsv.NewConverter(bw)
conv := fitcsv.NewFITToCSVConv(bw)
defer conv.Wait()
dec := decoder.New(f,
Expand All @@ -415,11 +417,25 @@ func main() {
Example:

```go
al := filedef.NewListener()
lis := filedef.NewListener()
defer lis.Close()
dec := decoder.New(f,
decoder.WithMesgListener(al),
decoder.WithMesgListener(lis),
decoder.WithBroadcastOnly(),
)
```

1. **WithBroadcastMesgCopy**: directs the Decoder to copy the mesg before passing it to listeners. It was the default behavior on <= v0.14.0.

```go
lis := NewLegacyNonBlockingListener() /* any legacy non-blocking listener created on version <= v0.14.0) */
dec := decoder.New(f,
decoder.WithMesgListener(lis),
decoder.WithBroadcastOnly(),
decoder.WithBroadcastMesgCopy(),
)
```

1. **WithIgnoreChecksum**: directs the decoder to ignore the checksum, which is useful when we want to retrieve the data without considering its integrity.
Expand All @@ -438,10 +454,11 @@ func main() {
dec := decoder.New(f, decoder.WithNoComponentExpansion())
```

1. **WithLogWriter**: specifies where the log messages will be written to. By default, the Decoder writes log message to io.Discard.
The Decoder will only write log messages when it encountered a bad encoded FIT file such as:
1. **WithLogWriter**: specifies where the log messages will be written to. By default, the Decoder do not write any log if log writer is not specified. The Decoder will only write log messages when it encountered a bad encoded FIT file such as:

- Field Definition's Size is less than its basetype's size. e.g. Size 1 byte but having basetype uint32 (4 bytes).
- Field Definition's Size (or Developer Field Definition's Size) is zero.
- Field Definition's Size (or Developer Field Definition's Size) is less than its basetype's size.
e.g. Size 1 byte but having basetype uint32 (4 bytes).
- Encounter a Developer Field without prior Field Description Message.
```go
Expand Down

0 comments on commit 9becca6

Please sign in to comment.