basetype

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package basetype defines the base of all types used in FIT. It is manually coded since Profile.xlsx does not provided same level details as it is defined on https://developer.garmin.com/fit/protocol.

This package refer to SDK -> Profile.xlsx (Sheet Name: "Types", Type Name (Column A): "fit_base_type") and is segregated since it's a special type. When code generation is generating types from Profile.xlsx and encounter type name "fit_base_type", that type name should not be generated to avoid unnecessary redundancy and confusion.

Index

Constants

View Source
const (
	EnumInvalid    byte   = math.MaxUint8  // 0xFF
	Sint8Invalid   int8   = math.MaxInt8   // 0x7F
	Uint8Invalid   uint8  = math.MaxUint8  // 0xFF
	Sint16Invalid  int16  = math.MaxInt16  // 0x7FFF
	Uint16Invalid  uint16 = math.MaxUint16 // 0xFFFF
	Sint32Invalid  int32  = math.MaxInt32  // 0x7FFFFFFF
	Uint32Invalid  uint32 = math.MaxUint32 // 0xFFFFFFFF
	StringInvalid  string = ""             // We use empty string to represent an invalid string in Go. However, it will be converted automatically into an utf8 null-terminated string "\x00" by the Value Marshaler.
	Float32Invalid uint32 = math.MaxUint32 // 0xFFFFFFFF. math.Float32frombits(0xFFFFFFFF) produces float64 NaN which is uncomparable. Can only check in its integer form e.g. math.Float32bits(float32value) == Float32Invalid.
	Float64Invalid uint64 = math.MaxUint64 // 0xFFFFFFFFFFFFFFFF. math.Float64frombits(0xFFFFFFFFFFFFFFFF) produces float64 NaN which is uncomparable. Can only check in its integer form e.g. math.Float64bits(float64value) == Float64Invalid.
	Uint8zInvalid  uint8  = 0              // 0x00
	Uint16zInvalid uint16 = 0              // 0x0000
	Uint32zInvalid uint32 = 0              // 0x00000000
	ByteInvalid    byte   = math.MaxUint8  // 0xFF
	Sint64Invalid  int64  = math.MaxInt64  // 0x7FFFFFFFFFFFFFFF
	Uint64Invalid  uint64 = math.MaxUint64 // 0xFFFFFFFFFFFFFFFF
	Uint64zInvalid uint64 = 0              // 0x0000000000000000
)
View Source
const BaseTypeNumMask = 0x1F

BaseTypeNumMask used to get the index/order of the constants (start from 0, Enum). Example: (Sint16 & BaseTypeNumMask) -> 3.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseType

type BaseType byte

BaseType is the base of all types used in FIT.

const (
	Enum    BaseType = 0x00
	Sint8   BaseType = 0x01 // 2’s complement format
	Uint8   BaseType = 0x02
	Sint16  BaseType = 0x83 // 2’s complement format
	Uint16  BaseType = 0x84
	Sint32  BaseType = 0x85 // 2’s complement format
	Uint32  BaseType = 0x86
	String  BaseType = 0x07 // Null terminated string encoded in UTF-8 format: 0x00
	Float32 BaseType = 0x88
	Float64 BaseType = 0x89
	Uint8z  BaseType = 0x0A
	Uint16z BaseType = 0x8B
	Uint32z BaseType = 0x8C
	Byte    BaseType = 0x0D // Array of bytes. Field is invalid if all bytes are invalid.
	Sint64  BaseType = 0x8E // 2’s complement format
	Uint64  BaseType = 0x8F
	Uint64z BaseType = 0x90
)

func FromString

func FromString(s string) BaseType

FromString convert given s into BaseType, if not valid 255 will be returned.

func List

func List() []BaseType

List returns all constants.

func (BaseType) EndianAbility

func (t BaseType) EndianAbility() byte

EndianAbility return whether t have endianness.

func (BaseType) GoType

func (t BaseType) GoType() string

GoType returns go equivalent type in string.

func (BaseType) Invalid

func (t BaseType) Invalid() any

Invalid returns invalid value of t. e.g. Byte is 255 (its highest value).

func (BaseType) IsInteger

func (t BaseType) IsInteger() bool

func (BaseType) Size

func (t BaseType) Size() byte

Size returns how many bytes it needs in binary form. If BaseType is invalid, zero will be returned.

func (BaseType) String

func (t BaseType) String() string

String returns string representation of t.

func (BaseType) Valid added in v0.17.0

func (t BaseType) Valid() bool

Valid checks whether BaseType is valid or not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL