-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c935a0e
Showing
70 changed files
with
11,708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
|
||
# vim | ||
[._]*.s[a-w][a-z] | ||
[._]s[a-w][a-z] | ||
*.un~ | ||
Session.vim | ||
.netrwhist | ||
*~ | ||
|
||
# go-fuzz | ||
workdir | ||
fit-fuzz.zip | ||
|
||
# binaries | ||
cmd/fitgenprofile/fitgenprofile | ||
cmd/stringer/stringer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: go | ||
|
||
go: | ||
- 1.4 | ||
- 1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Contributing | ||
|
||
I'm grateful for any help, whether it's code, documentation, or spelling | ||
corrections. | ||
|
||
## Filing issues | ||
|
||
Please report at least Go version, operating system and processor architecture | ||
when filing an issue. | ||
|
||
## Contributing code | ||
|
||
Please follow standard Go conventions and make sure that invoking ```make``` in | ||
the root directory reports no errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Tormod Erevik Lea | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
.PHONY: \ | ||
all \ | ||
test \ | ||
testrace \ | ||
bench \ | ||
fmt \ | ||
vet \ | ||
lint \ | ||
style \ | ||
fitgenprofile \ | ||
gofuzz \ | ||
gofuzzclean \ | ||
clean \ | ||
profcpu \ | ||
profmem \ | ||
profobj \ | ||
mdgen \ | ||
|
||
all: fmt vet test testrace | ||
|
||
test: | ||
go test -v ./... | ||
|
||
testrace: test | ||
go test -v -race ./... | ||
|
||
bench: | ||
go test -v -run NONE -bench . | ||
|
||
fmt: | ||
gofmt -l -s . dyncrc16 cmd/fitgen cmd/fitgen/internal/profile | ||
|
||
vet: | ||
go vet ./... | ||
|
||
lint: | ||
golint . | \ | ||
grep -v types_string.go | \ | ||
grep -v types.go | \ | ||
grep -v types_man.go | \ | ||
grep -v messages.go | \ | ||
grep -v profile.go | \ | ||
grep -v stringer.go | \ | ||
grep -v fileId | \ | ||
grep -v FileId | ||
golint dyncrc16 | ||
golint cmd/fitgen | ||
|
||
style: fmt vet lint | ||
|
||
fitgen: | ||
go install github.com/tormoder/gofit/cmd/fitgen | ||
|
||
gofuzz: | ||
go get -u github.com/dvyukov/go-fuzz/go-fuzz | ||
go get -u github.com/dvyukov/go-fuzz/go-fuzz-build | ||
go-fuzz-build github.com/tormoder/gofit | ||
|
||
gofuzzclean: gofuzz | ||
rm -rf workdir/ | ||
mkdir -p workdir/corpus | ||
cp testdata/me/activity-small-fenix2-run.fit workdir/corpus/ | ||
cp testdata/fitsdk/Activity.fit workdir/corpus/ | ||
cp testdata/fitsdk/Settings.fit workdir/corpus/ | ||
|
||
clean: | ||
rm -rf profile/*.csv | ||
rm -rf profile/*.xlsx | ||
rm -f fit-fuzz.zip | ||
rm -f *.prof | ||
rm -f *.test | ||
|
||
profcpu: | ||
go test -run=NONE -bench=ActivitySmall -cpuprofile cpu.prof | ||
go tool pprof gofit.test cpu.prof | ||
|
||
profmem: | ||
go test -run=NONE -bench=ActivitySmall -memprofile allocmem.prof | ||
go tool pprof -alloc_space gofit.test allocmem.prof | ||
|
||
profobj: | ||
go test -run=NONE -bench=ActivitySmall -memprofile allocobj.prof | ||
go tool pprof -alloc_objects gofit.test allocobj.prof | ||
|
||
mdgen: | ||
godoc2md github.com/tormoder/gofit Fit Header CheckIntegrity > MainApiReference.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# gofit | ||
|
||
[![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tormoder/gofit/raw/master/LICENSE) | ||
[![GoDoc](https://godoc.org/github.com/tormoder/gofit?status.svg)](https://godoc.org/github.com/tormoder/gofit) | ||
[![Build Status](https://travis-ci.org/tormoder/gofit.svg?branch=master)](https://travis-ci.org/tormoder/gofit) | ||
|
||
<img src="https://raw.githubusercontent.com/hackraft/gophericons/master/png/2.png" width="225" align="right" hspace="25" /> | ||
|
||
**This library is at the moment very much in flux.** | ||
|
||
gofit is a [Go](http://www.golang.org/) package that implements decoding of the | ||
[Flexible and Interoperable Data Transfer (FIT) | ||
Protocol](http://www.thisisant.com/resources/fit). Fit is a "compact binary | ||
format designed for storing and sharing data from sport, fitness and health | ||
devices". Fit files are created by newer GPS enabled Garmin sport watches and | ||
cycling computers, such as their Forerunner/Edge/Fenix series. gofit supports | ||
generating Go code for custom FIT product profiles. | ||
|
||
**Current supported FIT SDK version:** 16.10 | ||
|
||
### About gofit | ||
|
||
- [Example Usage](https://github.com/tormoder/gofit/wiki/Example-Usage) | ||
- [Data Types](https://github.com/tormoder/gofit/wiki/Data-Types) | ||
- [Main API Reference](https://github.com/tormoder/gofit/wiki/Main-Api-Reference) | ||
- [Custom Product Profiles](https://github.com/tormoder/gofit/wiki/Custom-Product-Profiles) | ||
- [Upcoming Features](https://github.com/tormoder/gofit/wiki/Upcoming-Features) | ||
- [Contributing](https://github.com/tormoder/gofit/blob/master/CONTRIBUTING.md) | ||
- [License](https://github.com/tormoder/gofit/wiki/License.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package fit | ||
|
||
const baseTypeNumMask = 0x1F | ||
|
||
type fitBaseType byte | ||
|
||
const ( | ||
fitEnum fitBaseType = 0x00 | ||
fitSint8 fitBaseType = 0x01 // 2's complement format | ||
fitUint8 fitBaseType = 0x02 | ||
fitSint16 fitBaseType = 0x83 // 2's complement format | ||
fitUint16 fitBaseType = 0x84 | ||
fitSint32 fitBaseType = 0x85 // 2's complement format | ||
fitUint32 fitBaseType = 0x86 | ||
fitString fitBaseType = 0x07 // Null terminated string encoded in UTF-8 | ||
fitFloat32 fitBaseType = 0x88 | ||
fitFloat64 fitBaseType = 0x89 | ||
fitUint8z fitBaseType = 0x0A | ||
fitUint16z fitBaseType = 0x8B | ||
fitUint32z fitBaseType = 0x8C | ||
fitByte fitBaseType = 0x0D // Array of bytes. Field is invalid if all bytes are invalid | ||
) | ||
|
||
func (b fitBaseType) nr() int { | ||
return int(b & baseTypeNumMask) | ||
} | ||
|
||
func (b fitBaseType) endianAbility() bool { | ||
return bsize[b.nr()] > 0 | ||
} | ||
|
||
func (b fitBaseType) integer() bool { | ||
return binteger[b.nr()] | ||
} | ||
|
||
func (b fitBaseType) signed() bool { | ||
return bsigned[b.nr()] | ||
} | ||
|
||
func (b fitBaseType) size() int { | ||
return bsize[b.nr()] | ||
} | ||
|
||
func (b fitBaseType) String() string { | ||
return bname[b.nr()] | ||
} | ||
|
||
var fitBaseTypes = [...]string{ | ||
"enum", | ||
"sint8", | ||
"uint8", | ||
"sint16", | ||
"uint16", | ||
"sint32", | ||
"uint32", | ||
"string", | ||
"float32", | ||
"float64", | ||
"uint8z", | ||
"uint16z", | ||
"uint32z", | ||
"byte", | ||
} | ||
|
||
var bsize = [...]int{ | ||
1, | ||
1, | ||
1, | ||
2, | ||
2, | ||
4, | ||
4, | ||
1, | ||
4, | ||
8, | ||
1, | ||
2, | ||
4, | ||
1, | ||
} | ||
|
||
var bname = [...]string{ | ||
"enum", | ||
"sint8", | ||
"uint8", | ||
"sint16", | ||
"uint16", | ||
"sint32", | ||
"uint32", | ||
"string", | ||
"float32", | ||
"float64", | ||
"uint8z", | ||
"uint16z", | ||
"uint32z", | ||
"byte", | ||
} | ||
|
||
var binteger = [...]bool{ | ||
false, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
false, | ||
false, | ||
false, | ||
true, | ||
true, | ||
true, | ||
false, | ||
} | ||
|
||
var bsigned = [...]bool{ | ||
false, | ||
true, | ||
false, | ||
true, | ||
false, | ||
true, | ||
false, | ||
false, | ||
true, | ||
true, | ||
false, | ||
false, | ||
false, | ||
false, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# fitgen | ||
|
||
```fitgen``` is a program that given a FIT profile generates Go code for | ||
[gofit](https://github.com/tormoder/gofit). It takes as input the official FIT profile | ||
specification workbook and outputs Go type, message and profile definitions. | ||
|
||
Consult the [Wiki](https://github.com/tormoder/gofit/wiki/Profile-Generation) | ||
for information about profile generation. | ||
|
||
```fitgen``` has only been tested on Linux x86-64. | ||
|
||
## Prerequisites | ||
|
||
* ```$GOPATH``` set. | ||
* Python 3 available in ```$PATH``` (xlsx to csv conversion). | ||
* [xlrd](https://pypi.python.org/pypi/xlrd) Python library (xlsx to csv conversion). | ||
* FIT SDK Zip file available. | ||
|
||
## Usage | ||
|
||
```shell | ||
usage: fitgenprofile [-keep] [path to sdk zip, xls or xlsx file] | ||
-jmptable | ||
use jump tables for profile message and field lookups, otherwise use switches (default true) | ||
-keep | ||
don't delete intermediary workbook and csv files from profile directory | ||
-sdk string | ||
provide or override SDK version printed in generated code | ||
``` |
Oops, something went wrong.