rubyfit 0.0.11 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rubyfit/fit.c +418 -412
- data/ext/rubyfit/fit.h +397 -380
- data/ext/rubyfit/fit_config.h +37 -36
- data/ext/rubyfit/fit_convert.c +619 -596
- data/ext/rubyfit/fit_convert.h +213 -203
- data/ext/rubyfit/fit_crc.c +67 -67
- data/ext/rubyfit/fit_crc.h +42 -42
- data/ext/rubyfit/fit_example.c +1512 -1431
- data/ext/rubyfit/fit_example.h +8000 -6147
- data/ext/rubyfit/fit_include.h +19 -19
- data/ext/rubyfit/fit_ram.c +211 -203
- data/ext/rubyfit/fit_ram.h +44 -39
- data/ext/rubyfit/rubyfit.c +560 -566
- data/lib/rubyfit/version.rb +1 -1
- metadata +3 -3
data/ext/rubyfit/fit_convert.h
CHANGED
@@ -1,203 +1,213 @@
|
|
1
|
-
////////////////////////////////////////////////////////////////////////////////
|
2
|
-
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
-
// devices only and remains the copyrighted property of
|
4
|
-
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
|
-
// and therefore all warranties, representations, or guarantees of any kind
|
6
|
-
// (whether express, implied or statutory) including, without limitation,
|
7
|
-
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
|
-
// purpose, are specifically disclaimed.
|
9
|
-
//
|
10
|
-
// Copyright
|
11
|
-
////////////////////////////////////////////////////////////////////////////////
|
12
|
-
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
-
// Profile Version =
|
14
|
-
// Tag = production/akw/
|
15
|
-
// Product = EXAMPLE
|
16
|
-
// Alignment = 4 bytes, padding disabled.
|
17
|
-
////////////////////////////////////////////////////////////////////////////////
|
18
|
-
|
19
|
-
|
20
|
-
#if !defined(FIT_CONVERT_H)
|
21
|
-
#define FIT_CONVERT_H
|
22
|
-
|
23
|
-
#include "fit_example.h"
|
24
|
-
|
25
|
-
|
26
|
-
//////////////////////////////////////////////////////////////////////////////////
|
27
|
-
// Public Definitions
|
28
|
-
//////////////////////////////////////////////////////////////////////////////////
|
29
|
-
|
30
|
-
typedef enum
|
31
|
-
{
|
32
|
-
FIT_CONVERT_CONTINUE = 0,
|
33
|
-
FIT_CONVERT_MESSAGE_AVAILABLE,
|
34
|
-
FIT_CONVERT_ERROR,
|
35
|
-
FIT_CONVERT_END_OF_FILE,
|
36
|
-
FIT_CONVERT_PROTOCOL_VERSION_NOT_SUPPORTED,
|
37
|
-
FIT_CONVERT_DATA_TYPE_NOT_SUPPORTED,
|
38
|
-
FIT_CONVERT_MESSAGE_NUMBER_FOUND
|
39
|
-
} FIT_CONVERT_RETURN;
|
40
|
-
|
41
|
-
typedef enum
|
42
|
-
{
|
43
|
-
FIT_CONVERT_DECODE_FILE_HDR,
|
44
|
-
FIT_CONVERT_DECODE_RECORD,
|
45
|
-
FIT_CONVERT_DECODE_RESERVED1,
|
46
|
-
FIT_CONVERT_DECODE_ARCH,
|
47
|
-
FIT_CONVERT_DECODE_GTYPE_1,
|
48
|
-
FIT_CONVERT_DECODE_GTYPE_2,
|
49
|
-
FIT_CONVERT_DECODE_NUM_FIELD_DEFS,
|
50
|
-
FIT_CONVERT_DECODE_FIELD_DEF,
|
51
|
-
FIT_CONVERT_DECODE_FIELD_DEF_SIZE,
|
52
|
-
FIT_CONVERT_DECODE_FIELD_BASE_TYPE,
|
53
|
-
FIT_CONVERT_DECODE_NUM_DEV_FIELDS,
|
54
|
-
FIT_CONVERT_DECODE_DEV_FIELD_DEF,
|
55
|
-
FIT_CONVERT_DECODE_DEV_FIELD_SIZE,
|
56
|
-
FIT_CONVERT_DECODE_DEV_FIELD_INDEX,
|
57
|
-
FIT_CONVERT_DECODE_FIELD_DATA,
|
58
|
-
FIT_CONVERT_DECODE_DEV_FIELD_DATA
|
59
|
-
} FIT_CONVERT_DECODE_STATE;
|
60
|
-
|
61
|
-
typedef struct
|
62
|
-
{
|
63
|
-
FIT_UINT32 file_bytes_left;
|
64
|
-
FIT_UINT32 data_offset;
|
65
|
-
#if defined(FIT_CONVERT_TIME_RECORD)
|
66
|
-
FIT_UINT32 timestamp;
|
67
|
-
#endif
|
68
|
-
union
|
69
|
-
{
|
70
|
-
FIT_FILE_HDR file_hdr;
|
71
|
-
FIT_UINT8 mesg[FIT_MESG_SIZE];
|
72
|
-
}u;
|
73
|
-
FIT_MESG_CONVERT convert_table[FIT_LOCAL_MESGS];
|
74
|
-
const FIT_MESG_DEF *mesg_def;
|
75
|
-
#if defined(FIT_CONVERT_CHECK_CRC)
|
76
|
-
FIT_UINT16 crc;
|
77
|
-
#endif
|
78
|
-
FIT_CONVERT_DECODE_STATE decode_state;
|
79
|
-
FIT_BOOL has_dev_data;
|
80
|
-
FIT_UINT8 mesg_index;
|
81
|
-
|
82
|
-
FIT_UINT8 dev_data_sizes[FIT_MAX_LOCAL_MESGS];
|
83
|
-
|
84
|
-
FIT_UINT8 num_fields;
|
85
|
-
FIT_UINT8 field_num;
|
86
|
-
FIT_UINT8 field_index;
|
87
|
-
FIT_UINT8 field_offset;
|
88
|
-
#if defined(FIT_CONVERT_TIME_RECORD)
|
89
|
-
FIT_UINT8 last_time_offset;
|
90
|
-
#endif
|
91
|
-
} FIT_CONVERT_STATE;
|
92
|
-
|
93
|
-
|
94
|
-
//////////////////////////////////////////////////////////////////////////////////
|
95
|
-
// Public Function Prototypes
|
96
|
-
//////////////////////////////////////////////////////////////////////////////////
|
97
|
-
|
98
|
-
#if defined(__cplusplus)
|
99
|
-
extern "C" {
|
100
|
-
#endif
|
101
|
-
|
102
|
-
///////////////////////////////////////////////////////////////////////
|
103
|
-
// Initialize the state of the converter to start parsing the file.
|
104
|
-
///////////////////////////////////////////////////////////////////////
|
105
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
106
|
-
void FitConvert_Init(FIT_CONVERT_STATE *state, FIT_BOOL read_file_header);
|
107
|
-
#else
|
108
|
-
void FitConvert_Init(FIT_BOOL read_file_header);
|
109
|
-
#endif
|
110
|
-
|
111
|
-
///////////////////////////////////////////////////////////////////////
|
112
|
-
// Convert a stream of bytes.
|
113
|
-
// Parameters:
|
114
|
-
// state Pointer to converter state.
|
115
|
-
// data Pointer to a buffer containing bytes from the file stream.
|
116
|
-
// size Number of bytes in the data buffer.
|
117
|
-
//
|
118
|
-
// Returns FIT_CONVERT_CONTINUE when the all bytes in data have
|
119
|
-
// been decoded successfully and ready to accept next bytes in the
|
120
|
-
// file stream. No message is available yet.
|
121
|
-
// Returns FIT_CONVERT_MESSAGE_AVAILABLE when a message is
|
122
|
-
// complete. The message is valid until this function is called
|
123
|
-
// again.
|
124
|
-
// Returns FIT_CONVERT_ERROR if a decoding error occurs.
|
125
|
-
// Returns FIT_CONVERT_END_OF_FILE when the file has been decoded successfully.
|
126
|
-
///////////////////////////////////////////////////////////////////////
|
127
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
128
|
-
FIT_CONVERT_RETURN FitConvert_Read(FIT_CONVERT_STATE *state, const void *data, FIT_UINT32 size);
|
129
|
-
#else
|
130
|
-
FIT_CONVERT_RETURN FitConvert_Read(const void *data, FIT_UINT32 size);
|
131
|
-
#endif
|
132
|
-
|
133
|
-
///////////////////////////////////////////////////////////////////////
|
134
|
-
// Convert a stream of bytes.
|
135
|
-
// Parameters:
|
136
|
-
// state Pointer to converter state.
|
137
|
-
// data Pointer to a buffer containing bytes from the file stream.
|
138
|
-
// size Number of bytes in the data buffer.
|
139
|
-
// return_message_numbers Returns when a message number has been found in a message definition
|
140
|
-
// This is useful when needing to force fit_convert to use an alternate message definition
|
141
|
-
//
|
142
|
-
// Returns FIT_CONVERT_CONTINUE when the all bytes in data have
|
143
|
-
// been decoded successfully and ready to accept next bytes in the
|
144
|
-
// file stream. No message is available yet.
|
145
|
-
// Returns FIT_CONVERT_MESSAGE_AVAILABLE when a message is
|
146
|
-
// complete. The message is valid until this function is called
|
147
|
-
// again.
|
148
|
-
// Returns FIT_CONVERT_MESSAGE_NUMBER_FOUND when a new message number
|
149
|
-
// has been found in a message definition.
|
150
|
-
// Returns FIT_CONVERT_ERROR if a decoding error occurs.
|
151
|
-
// Returns FIT_CONVERT_END_OF_FILE when the file has been decoded successfully.
|
152
|
-
///////////////////////////////////////////////////////////////////////
|
153
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
154
|
-
FIT_CONVERT_RETURN FitConvert_ReadExt(FIT_CONVERT_STATE *state, const void *data, FIT_UINT32 size, FIT_BOOL return_message_numbers);
|
155
|
-
#else
|
156
|
-
FIT_CONVERT_RETURN FitConvert_ReadExt(const void *data, FIT_UINT32 size, FIT_BOOL return_message_numbers);
|
157
|
-
#endif
|
158
|
-
|
159
|
-
///////////////////////////////////////////////////////////////////////
|
160
|
-
// Overrides the message definition to be used when
|
161
|
-
// decoding the message.
|
162
|
-
// In a multithreaded environment, you can set the state directly
|
163
|
-
// in FitConvert_ReadExt().
|
164
|
-
///////////////////////////////////////////////////////////////////////
|
165
|
-
#if !defined(FIT_CONVERT_MULTI_THREAD)
|
166
|
-
void FitConvert_SetMessageDefinition(FIT_MESG_DEF *mesg_def);
|
167
|
-
#endif
|
168
|
-
|
169
|
-
///////////////////////////////////////////////////////////////////////
|
170
|
-
// Returns the global message number of the decoded message.
|
171
|
-
///////////////////////////////////////////////////////////////////////
|
172
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
173
|
-
FIT_MESG_NUM FitConvert_GetMessageNumber(FIT_CONVERT_STATE *state);
|
174
|
-
#else
|
175
|
-
FIT_MESG_NUM FitConvert_GetMessageNumber(void);
|
176
|
-
#endif
|
177
|
-
|
178
|
-
///////////////////////////////////////////////////////////////////////
|
179
|
-
// Returns a pointer to the data of the decoded message.
|
180
|
-
// Copy or cast to FIT_*_MESG structure.
|
181
|
-
///////////////////////////////////////////////////////////////////////
|
182
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
183
|
-
const FIT_UINT8 *FitConvert_GetMessageData(FIT_CONVERT_STATE *state);
|
184
|
-
#else
|
185
|
-
const FIT_UINT8 *FitConvert_GetMessageData(void);
|
186
|
-
#endif
|
187
|
-
|
188
|
-
///////////////////////////////////////////////////////////////////////
|
189
|
-
// Restores fields that are not in decoded message from mesg_data.
|
190
|
-
// Use when modifying an existing file.
|
191
|
-
///////////////////////////////////////////////////////////////////////
|
192
|
-
#if defined(FIT_CONVERT_MULTI_THREAD)
|
193
|
-
void FitConvert_RestoreFields(FIT_CONVERT_STATE *state, const void *mesg_data);
|
194
|
-
#else
|
195
|
-
void FitConvert_RestoreFields(const void *mesg_data);
|
196
|
-
#endif
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
#
|
203
|
-
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Garmin Canada Inc.
|
4
|
+
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
|
+
// and therefore all warranties, representations, or guarantees of any kind
|
6
|
+
// (whether express, implied or statutory) including, without limitation,
|
7
|
+
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
|
+
// purpose, are specifically disclaimed.
|
9
|
+
//
|
10
|
+
// Copyright 2020 Garmin Canada Inc.
|
11
|
+
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 21.27Release
|
14
|
+
// Tag = production/akw/21.27.00-0-gef9575d
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
18
|
+
|
19
|
+
|
20
|
+
#if !defined(FIT_CONVERT_H)
|
21
|
+
#define FIT_CONVERT_H
|
22
|
+
|
23
|
+
#include "fit_example.h"
|
24
|
+
|
25
|
+
|
26
|
+
//////////////////////////////////////////////////////////////////////////////////
|
27
|
+
// Public Definitions
|
28
|
+
//////////////////////////////////////////////////////////////////////////////////
|
29
|
+
|
30
|
+
typedef enum
|
31
|
+
{
|
32
|
+
FIT_CONVERT_CONTINUE = 0,
|
33
|
+
FIT_CONVERT_MESSAGE_AVAILABLE,
|
34
|
+
FIT_CONVERT_ERROR,
|
35
|
+
FIT_CONVERT_END_OF_FILE,
|
36
|
+
FIT_CONVERT_PROTOCOL_VERSION_NOT_SUPPORTED,
|
37
|
+
FIT_CONVERT_DATA_TYPE_NOT_SUPPORTED,
|
38
|
+
FIT_CONVERT_MESSAGE_NUMBER_FOUND
|
39
|
+
} FIT_CONVERT_RETURN;
|
40
|
+
|
41
|
+
typedef enum
|
42
|
+
{
|
43
|
+
FIT_CONVERT_DECODE_FILE_HDR,
|
44
|
+
FIT_CONVERT_DECODE_RECORD,
|
45
|
+
FIT_CONVERT_DECODE_RESERVED1,
|
46
|
+
FIT_CONVERT_DECODE_ARCH,
|
47
|
+
FIT_CONVERT_DECODE_GTYPE_1,
|
48
|
+
FIT_CONVERT_DECODE_GTYPE_2,
|
49
|
+
FIT_CONVERT_DECODE_NUM_FIELD_DEFS,
|
50
|
+
FIT_CONVERT_DECODE_FIELD_DEF,
|
51
|
+
FIT_CONVERT_DECODE_FIELD_DEF_SIZE,
|
52
|
+
FIT_CONVERT_DECODE_FIELD_BASE_TYPE,
|
53
|
+
FIT_CONVERT_DECODE_NUM_DEV_FIELDS,
|
54
|
+
FIT_CONVERT_DECODE_DEV_FIELD_DEF,
|
55
|
+
FIT_CONVERT_DECODE_DEV_FIELD_SIZE,
|
56
|
+
FIT_CONVERT_DECODE_DEV_FIELD_INDEX,
|
57
|
+
FIT_CONVERT_DECODE_FIELD_DATA,
|
58
|
+
FIT_CONVERT_DECODE_DEV_FIELD_DATA
|
59
|
+
} FIT_CONVERT_DECODE_STATE;
|
60
|
+
|
61
|
+
typedef struct
|
62
|
+
{
|
63
|
+
FIT_UINT32 file_bytes_left;
|
64
|
+
FIT_UINT32 data_offset;
|
65
|
+
#if defined(FIT_CONVERT_TIME_RECORD)
|
66
|
+
FIT_UINT32 timestamp;
|
67
|
+
#endif
|
68
|
+
union
|
69
|
+
{
|
70
|
+
FIT_FILE_HDR file_hdr;
|
71
|
+
FIT_UINT8 mesg[FIT_MESG_SIZE];
|
72
|
+
}u;
|
73
|
+
FIT_MESG_CONVERT convert_table[FIT_LOCAL_MESGS];
|
74
|
+
const FIT_MESG_DEF *mesg_def;
|
75
|
+
#if defined(FIT_CONVERT_CHECK_CRC)
|
76
|
+
FIT_UINT16 crc;
|
77
|
+
#endif
|
78
|
+
FIT_CONVERT_DECODE_STATE decode_state;
|
79
|
+
FIT_BOOL has_dev_data;
|
80
|
+
FIT_UINT8 mesg_index;
|
81
|
+
FIT_UINT16 mesg_sizes[FIT_MAX_LOCAL_MESGS];
|
82
|
+
FIT_UINT8 dev_data_sizes[FIT_MAX_LOCAL_MESGS];
|
83
|
+
FIT_UINT16 mesg_offset;
|
84
|
+
FIT_UINT8 num_fields;
|
85
|
+
FIT_UINT8 field_num;
|
86
|
+
FIT_UINT8 field_index;
|
87
|
+
FIT_UINT8 field_offset;
|
88
|
+
#if defined(FIT_CONVERT_TIME_RECORD)
|
89
|
+
FIT_UINT8 last_time_offset;
|
90
|
+
#endif
|
91
|
+
} FIT_CONVERT_STATE;
|
92
|
+
|
93
|
+
|
94
|
+
//////////////////////////////////////////////////////////////////////////////////
|
95
|
+
// Public Function Prototypes
|
96
|
+
//////////////////////////////////////////////////////////////////////////////////
|
97
|
+
|
98
|
+
#if defined(__cplusplus)
|
99
|
+
extern "C" {
|
100
|
+
#endif
|
101
|
+
|
102
|
+
///////////////////////////////////////////////////////////////////////
|
103
|
+
// Initialize the state of the converter to start parsing the file.
|
104
|
+
///////////////////////////////////////////////////////////////////////
|
105
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
106
|
+
void FitConvert_Init(FIT_CONVERT_STATE *state, FIT_BOOL read_file_header);
|
107
|
+
#else
|
108
|
+
void FitConvert_Init(FIT_BOOL read_file_header);
|
109
|
+
#endif
|
110
|
+
|
111
|
+
///////////////////////////////////////////////////////////////////////
|
112
|
+
// Convert a stream of bytes.
|
113
|
+
// Parameters:
|
114
|
+
// state Pointer to converter state.
|
115
|
+
// data Pointer to a buffer containing bytes from the file stream.
|
116
|
+
// size Number of bytes in the data buffer.
|
117
|
+
//
|
118
|
+
// Returns FIT_CONVERT_CONTINUE when the all bytes in data have
|
119
|
+
// been decoded successfully and ready to accept next bytes in the
|
120
|
+
// file stream. No message is available yet.
|
121
|
+
// Returns FIT_CONVERT_MESSAGE_AVAILABLE when a message is
|
122
|
+
// complete. The message is valid until this function is called
|
123
|
+
// again.
|
124
|
+
// Returns FIT_CONVERT_ERROR if a decoding error occurs.
|
125
|
+
// Returns FIT_CONVERT_END_OF_FILE when the file has been decoded successfully.
|
126
|
+
///////////////////////////////////////////////////////////////////////
|
127
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
128
|
+
FIT_CONVERT_RETURN FitConvert_Read(FIT_CONVERT_STATE *state, const void *data, FIT_UINT32 size);
|
129
|
+
#else
|
130
|
+
FIT_CONVERT_RETURN FitConvert_Read(const void *data, FIT_UINT32 size);
|
131
|
+
#endif
|
132
|
+
|
133
|
+
///////////////////////////////////////////////////////////////////////
|
134
|
+
// Convert a stream of bytes.
|
135
|
+
// Parameters:
|
136
|
+
// state Pointer to converter state.
|
137
|
+
// data Pointer to a buffer containing bytes from the file stream.
|
138
|
+
// size Number of bytes in the data buffer.
|
139
|
+
// return_message_numbers Returns when a message number has been found in a message definition
|
140
|
+
// This is useful when needing to force fit_convert to use an alternate message definition
|
141
|
+
//
|
142
|
+
// Returns FIT_CONVERT_CONTINUE when the all bytes in data have
|
143
|
+
// been decoded successfully and ready to accept next bytes in the
|
144
|
+
// file stream. No message is available yet.
|
145
|
+
// Returns FIT_CONVERT_MESSAGE_AVAILABLE when a message is
|
146
|
+
// complete. The message is valid until this function is called
|
147
|
+
// again.
|
148
|
+
// Returns FIT_CONVERT_MESSAGE_NUMBER_FOUND when a new message number
|
149
|
+
// has been found in a message definition.
|
150
|
+
// Returns FIT_CONVERT_ERROR if a decoding error occurs.
|
151
|
+
// Returns FIT_CONVERT_END_OF_FILE when the file has been decoded successfully.
|
152
|
+
///////////////////////////////////////////////////////////////////////
|
153
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
154
|
+
FIT_CONVERT_RETURN FitConvert_ReadExt(FIT_CONVERT_STATE *state, const void *data, FIT_UINT32 size, FIT_BOOL return_message_numbers);
|
155
|
+
#else
|
156
|
+
FIT_CONVERT_RETURN FitConvert_ReadExt(const void *data, FIT_UINT32 size, FIT_BOOL return_message_numbers);
|
157
|
+
#endif
|
158
|
+
|
159
|
+
///////////////////////////////////////////////////////////////////////
|
160
|
+
// Overrides the message definition to be used when
|
161
|
+
// decoding the message.
|
162
|
+
// In a multithreaded environment, you can set the state directly
|
163
|
+
// in FitConvert_ReadExt().
|
164
|
+
///////////////////////////////////////////////////////////////////////
|
165
|
+
#if !defined(FIT_CONVERT_MULTI_THREAD)
|
166
|
+
void FitConvert_SetMessageDefinition(FIT_MESG_DEF *mesg_def);
|
167
|
+
#endif
|
168
|
+
|
169
|
+
///////////////////////////////////////////////////////////////////////
|
170
|
+
// Returns the global message number of the decoded message.
|
171
|
+
///////////////////////////////////////////////////////////////////////
|
172
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
173
|
+
FIT_MESG_NUM FitConvert_GetMessageNumber(FIT_CONVERT_STATE *state);
|
174
|
+
#else
|
175
|
+
FIT_MESG_NUM FitConvert_GetMessageNumber(void);
|
176
|
+
#endif
|
177
|
+
|
178
|
+
///////////////////////////////////////////////////////////////////////
|
179
|
+
// Returns a pointer to the data of the decoded message.
|
180
|
+
// Copy or cast to FIT_*_MESG structure.
|
181
|
+
///////////////////////////////////////////////////////////////////////
|
182
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
183
|
+
const FIT_UINT8 *FitConvert_GetMessageData(FIT_CONVERT_STATE *state);
|
184
|
+
#else
|
185
|
+
const FIT_UINT8 *FitConvert_GetMessageData(void);
|
186
|
+
#endif
|
187
|
+
|
188
|
+
///////////////////////////////////////////////////////////////////////
|
189
|
+
// Restores fields that are not in decoded message from mesg_data.
|
190
|
+
// Use when modifying an existing file.
|
191
|
+
///////////////////////////////////////////////////////////////////////
|
192
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
193
|
+
void FitConvert_RestoreFields(FIT_CONVERT_STATE *state, const void *mesg_data);
|
194
|
+
#else
|
195
|
+
void FitConvert_RestoreFields(const void *mesg_data);
|
196
|
+
#endif
|
197
|
+
|
198
|
+
///////////////////////////////////////////////////////////////////////
|
199
|
+
// Restores fields that are not in decoded message from mesg_data.
|
200
|
+
// Use when modifying an existing file.
|
201
|
+
///////////////////////////////////////////////////////////////////////
|
202
|
+
#if defined(FIT_CONVERT_MULTI_THREAD)
|
203
|
+
FIT_UINT8 FitConvert_GetFieldSize(FIT_CONVERT_STATE *state, FIT_UINT8 field);
|
204
|
+
#else
|
205
|
+
FIT_UINT8 FitConvert_GetFieldSize(FIT_UINT8 field);
|
206
|
+
#endif
|
207
|
+
|
208
|
+
#if defined(__cplusplus)
|
209
|
+
}
|
210
|
+
#endif
|
211
|
+
|
212
|
+
#endif // !defined(FIT_CONVERT_H)
|
213
|
+
|
data/ext/rubyfit/fit_crc.c
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
////////////////////////////////////////////////////////////////////////////////
|
2
|
-
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
-
// devices only and remains the copyrighted property of
|
4
|
-
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
|
-
// and therefore all warranties, representations, or guarantees of any kind
|
6
|
-
// (whether express, implied or statutory) including, without limitation,
|
7
|
-
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
|
-
// purpose, are specifically disclaimed.
|
9
|
-
//
|
10
|
-
// Copyright
|
11
|
-
////////////////////////////////////////////////////////////////////////////////
|
12
|
-
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
-
// Profile Version =
|
14
|
-
// Tag = production/akw/
|
15
|
-
// Product = EXAMPLE
|
16
|
-
// Alignment = 4 bytes, padding disabled.
|
17
|
-
////////////////////////////////////////////////////////////////////////////////
|
18
|
-
|
19
|
-
|
20
|
-
#include "fit_crc.h"
|
21
|
-
|
22
|
-
|
23
|
-
//////////////////////////////////////////////////////////////////////////////////
|
24
|
-
// Public Functions
|
25
|
-
//////////////////////////////////////////////////////////////////////////////////
|
26
|
-
|
27
|
-
FIT_UINT16 FitCRC_Get16(FIT_UINT16 crc, FIT_UINT8 byte)
|
28
|
-
{
|
29
|
-
static const FIT_UINT16 crc_table[16] =
|
30
|
-
{
|
31
|
-
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
|
32
|
-
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
|
33
|
-
};
|
34
|
-
FIT_UINT16 tmp;
|
35
|
-
|
36
|
-
// compute checksum of lower four bits of byte
|
37
|
-
tmp = crc_table[crc & 0xF];
|
38
|
-
crc = (crc >> 4) & 0x0FFF;
|
39
|
-
crc = crc ^ tmp ^ crc_table[byte & 0xF];
|
40
|
-
|
41
|
-
// now compute checksum of upper four bits of byte
|
42
|
-
tmp = crc_table[crc & 0xF];
|
43
|
-
crc = (crc >> 4) & 0x0FFF;
|
44
|
-
crc = crc ^ tmp ^ crc_table[(byte >> 4) & 0xF];
|
45
|
-
|
46
|
-
return crc;
|
47
|
-
}
|
48
|
-
|
49
|
-
FIT_UINT16 FitCRC_Update16(FIT_UINT16 crc, const volatile void *data, FIT_UINT32 size)
|
50
|
-
{
|
51
|
-
FIT_BYTE *data_ptr = (FIT_BYTE *)data;
|
52
|
-
|
53
|
-
while (size)
|
54
|
-
{
|
55
|
-
crc = FitCRC_Get16(crc, *data_ptr);
|
56
|
-
data_ptr++;
|
57
|
-
size--;
|
58
|
-
}
|
59
|
-
|
60
|
-
return crc;
|
61
|
-
}
|
62
|
-
|
63
|
-
FIT_UINT16 FitCRC_Calc16(const volatile void *data, FIT_UINT32 size)
|
64
|
-
{
|
65
|
-
return FitCRC_Update16(0, data, size);
|
66
|
-
}
|
67
|
-
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Garmin Canada Inc.
|
4
|
+
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
|
+
// and therefore all warranties, representations, or guarantees of any kind
|
6
|
+
// (whether express, implied or statutory) including, without limitation,
|
7
|
+
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
|
+
// purpose, are specifically disclaimed.
|
9
|
+
//
|
10
|
+
// Copyright 2020 Garmin Canada Inc.
|
11
|
+
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 21.27Release
|
14
|
+
// Tag = production/akw/21.27.00-0-gef9575d
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
18
|
+
|
19
|
+
|
20
|
+
#include "fit_crc.h"
|
21
|
+
|
22
|
+
|
23
|
+
//////////////////////////////////////////////////////////////////////////////////
|
24
|
+
// Public Functions
|
25
|
+
//////////////////////////////////////////////////////////////////////////////////
|
26
|
+
|
27
|
+
FIT_UINT16 FitCRC_Get16(FIT_UINT16 crc, FIT_UINT8 byte)
|
28
|
+
{
|
29
|
+
static const FIT_UINT16 crc_table[16] =
|
30
|
+
{
|
31
|
+
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
|
32
|
+
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
|
33
|
+
};
|
34
|
+
FIT_UINT16 tmp;
|
35
|
+
|
36
|
+
// compute checksum of lower four bits of byte
|
37
|
+
tmp = crc_table[crc & 0xF];
|
38
|
+
crc = (crc >> 4) & 0x0FFF;
|
39
|
+
crc = crc ^ tmp ^ crc_table[byte & 0xF];
|
40
|
+
|
41
|
+
// now compute checksum of upper four bits of byte
|
42
|
+
tmp = crc_table[crc & 0xF];
|
43
|
+
crc = (crc >> 4) & 0x0FFF;
|
44
|
+
crc = crc ^ tmp ^ crc_table[(byte >> 4) & 0xF];
|
45
|
+
|
46
|
+
return crc;
|
47
|
+
}
|
48
|
+
|
49
|
+
FIT_UINT16 FitCRC_Update16(FIT_UINT16 crc, const volatile void *data, FIT_UINT32 size)
|
50
|
+
{
|
51
|
+
FIT_BYTE *data_ptr = (FIT_BYTE *)data;
|
52
|
+
|
53
|
+
while (size)
|
54
|
+
{
|
55
|
+
crc = FitCRC_Get16(crc, *data_ptr);
|
56
|
+
data_ptr++;
|
57
|
+
size--;
|
58
|
+
}
|
59
|
+
|
60
|
+
return crc;
|
61
|
+
}
|
62
|
+
|
63
|
+
FIT_UINT16 FitCRC_Calc16(const volatile void *data, FIT_UINT32 size)
|
64
|
+
{
|
65
|
+
return FitCRC_Update16(0, data, size);
|
66
|
+
}
|
67
|
+
|