rubyfit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/rubyfit/fit.c +96 -25
- data/ext/rubyfit/fit.h +127 -44
- data/ext/rubyfit/fit_config.h +7 -7
- data/ext/rubyfit/fit_convert.c +66 -13
- data/ext/rubyfit/fit_convert.h +28 -23
- data/ext/rubyfit/fit_crc.c +30 -6
- data/ext/rubyfit/fit_crc.h +12 -5
- data/ext/rubyfit/fit_example.c +899 -0
- data/ext/rubyfit/fit_example.h +3299 -0
- data/ext/rubyfit/fit_ram.c +203 -0
- data/ext/rubyfit/fit_ram.h +39 -0
- data/ext/rubyfit/rubyfit.c +25 -36
- data/lib/rubyfit/version.rb +1 -1
- metadata +14 -16
- data/ext/rubyfit/fit_product.c +0 -21
- data/ext/rubyfit/fit_product.h +0 -21
- data/ext/rubyfit/fit_sdk.c +0 -618
- data/ext/rubyfit/fit_sdk.h +0 -2083
@@ -0,0 +1,203 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Dynastream Innovations 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 2013 Dynastream Innovations Inc.
|
11
|
+
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 8.10Release
|
14
|
+
// Tag = $Name: AKW8_100 $
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
18
|
+
|
19
|
+
|
20
|
+
#include <string.h>
|
21
|
+
|
22
|
+
#include "fit_ram.h"
|
23
|
+
#include "fit_crc.h"
|
24
|
+
#include "fit_convert.h"
|
25
|
+
|
26
|
+
#if defined(FIT_RAM_INCLUDE)
|
27
|
+
|
28
|
+
///////////////////////////////////////////////////////////////////////////////
|
29
|
+
// Private Variables
|
30
|
+
///////////////////////////////////////////////////////////////////////////////
|
31
|
+
|
32
|
+
static FIT_UINT32 read_crc_offset;
|
33
|
+
static FIT_UINT16 read_crc;
|
34
|
+
|
35
|
+
|
36
|
+
///////////////////////////////////////////////////////////////////////////////
|
37
|
+
// Public Functions
|
38
|
+
///////////////////////////////////////////////////////////////////////////////
|
39
|
+
|
40
|
+
FIT_RAM_FILE FitRAM_LookupFile(FIT_FILE file)
|
41
|
+
{
|
42
|
+
FIT_RAM_FILE ram_file;
|
43
|
+
|
44
|
+
for (ram_file = (FIT_RAM_FILE)0; ram_file < FIT_RAM_FILES; ram_file++)
|
45
|
+
{
|
46
|
+
if (file == fit_ram_files[ram_file]->file_def->type)
|
47
|
+
return ram_file;
|
48
|
+
}
|
49
|
+
|
50
|
+
return FIT_RAM_FILES;
|
51
|
+
}
|
52
|
+
|
53
|
+
FIT_UINT32 FitRAM_GetFileSize(FIT_RAM_FILE file)
|
54
|
+
{
|
55
|
+
if (file >= FIT_RAM_FILES)
|
56
|
+
return 0;
|
57
|
+
|
58
|
+
return FIT_FILE_HDR_SIZE + fit_ram_files[file]->file_def->data_size + sizeof(FIT_UINT16);
|
59
|
+
}
|
60
|
+
|
61
|
+
void FitRAM_FileReadBytes(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT32 file_offset, void *data, FIT_UINT32 data_size)
|
62
|
+
{
|
63
|
+
FIT_BYTE *data_ptr = (FIT_BYTE *) data;
|
64
|
+
const FIT_RAM_FILE_DATA *file_data = fit_ram_files[file]->data;
|
65
|
+
FIT_UINT16 data_index = 0;
|
66
|
+
FIT_UINT32 offset = file_offset;
|
67
|
+
FIT_UINT32 size;
|
68
|
+
FIT_UINT8 read_crc_size = 0;
|
69
|
+
|
70
|
+
if ((file_offset + data_size) > (FIT_FILE_HDR_SIZE + fit_ram_files[file]->file_def->data_size))
|
71
|
+
{
|
72
|
+
read_crc_size = (FIT_UINT8)((file_offset + data_size) - (FIT_FILE_HDR_SIZE + fit_ram_files[file]->file_def->data_size)); // Don't include file crc in copy.
|
73
|
+
data_size -= read_crc_size;
|
74
|
+
|
75
|
+
if (read_crc_size > 2)
|
76
|
+
read_crc_size = 2;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (data_size > 0)
|
80
|
+
{
|
81
|
+
do
|
82
|
+
{
|
83
|
+
while ((data_index < fit_ram_files[file]->data_count) && ((file_data->file_offset + file_data->size) <= offset))
|
84
|
+
{
|
85
|
+
file_data++;
|
86
|
+
data_index++;
|
87
|
+
}
|
88
|
+
|
89
|
+
if ((data_index >= fit_ram_files[file]->data_count) || (file_data->file_offset >= (file_offset + data_size)))
|
90
|
+
{
|
91
|
+
size = file_offset + data_size - offset;
|
92
|
+
memcpy(&data_ptr[offset - file_offset], &fit_ram_files[file]->file[offset], size);
|
93
|
+
offset += size;
|
94
|
+
break; // Done.
|
95
|
+
}
|
96
|
+
|
97
|
+
if (offset < file_data->file_offset)
|
98
|
+
{
|
99
|
+
size = file_data->file_offset - offset;
|
100
|
+
|
101
|
+
if ((offset + size) > (file_offset + data_size))
|
102
|
+
size = file_offset + data_size - offset;
|
103
|
+
|
104
|
+
memcpy(&data_ptr[offset - file_offset], &fit_ram_files[file]->file[offset], size);
|
105
|
+
offset += size;
|
106
|
+
}
|
107
|
+
|
108
|
+
size = offset + file_data->size;
|
109
|
+
|
110
|
+
if (size > (file_offset + data_size))
|
111
|
+
size = file_offset + data_size;
|
112
|
+
|
113
|
+
size -= offset;
|
114
|
+
memcpy(&data_ptr[offset - file_offset], &((FIT_BYTE *)file_data->data)[offset - file_data->file_offset], size);
|
115
|
+
offset += size;
|
116
|
+
} while (offset < (file_offset + data_size));
|
117
|
+
|
118
|
+
if (file_offset == 0)
|
119
|
+
{
|
120
|
+
read_crc = 0;
|
121
|
+
read_crc_offset = 0;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (file_offset > read_crc_offset)
|
125
|
+
read_crc_offset = file_offset; // Non-contiguous read. CRC will be invalid.
|
126
|
+
|
127
|
+
if ((file_offset + data_size) > read_crc_offset)
|
128
|
+
read_crc = FitCRC_Update16(read_crc, &data_ptr[read_crc_offset - file_offset], (FIT_UINT8)(file_offset + data_size - read_crc_offset));
|
129
|
+
|
130
|
+
read_crc_offset = file_offset + data_size;
|
131
|
+
}
|
132
|
+
|
133
|
+
if (read_crc_size > 0)
|
134
|
+
{
|
135
|
+
data_ptr[offset - file_offset] = (FIT_BYTE)read_crc;
|
136
|
+
offset++;
|
137
|
+
|
138
|
+
if (read_crc_size == 1)
|
139
|
+
return;
|
140
|
+
|
141
|
+
data_ptr[offset - file_offset] = (FIT_BYTE)(read_crc >> 8);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
void FitRAM_FileWriteBytes(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT32 file_offset, const void *data, FIT_UINT32 data_size)
|
146
|
+
{
|
147
|
+
const FIT_RAM_FILE_DATA *file_data;
|
148
|
+
FIT_UINT16 data_index;
|
149
|
+
FIT_BYTE *src;
|
150
|
+
FIT_BYTE *dest;
|
151
|
+
FIT_UINT32 size;
|
152
|
+
|
153
|
+
for (data_index = 0; data_index < fit_ram_files[file]->data_count; data_index++)
|
154
|
+
{
|
155
|
+
file_data = &fit_ram_files[file]->data[data_index];
|
156
|
+
|
157
|
+
if (file_data->file_offset >= (file_offset + data_size))
|
158
|
+
return; // Data start is after end of write so we are done.
|
159
|
+
|
160
|
+
if (file_offset >= (file_data->file_offset + file_data->size))
|
161
|
+
continue; // Data end is after write so continue to next data element.
|
162
|
+
|
163
|
+
src = (FIT_BYTE *) data;
|
164
|
+
dest = (FIT_BYTE *) file_data->data;
|
165
|
+
size = data_size;
|
166
|
+
|
167
|
+
if (file_offset < file_data->file_offset)
|
168
|
+
{
|
169
|
+
size -= file_data->file_offset - file_offset;
|
170
|
+
src += file_data->file_offset - file_offset;
|
171
|
+
}
|
172
|
+
else
|
173
|
+
{
|
174
|
+
dest += file_offset - file_data->file_offset;
|
175
|
+
}
|
176
|
+
|
177
|
+
if (size > file_data->size)
|
178
|
+
size = file_data->size;
|
179
|
+
|
180
|
+
memcpy(dest, src, size);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
void FitRAM_FileWriteMesg(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT16 mesg_num, const void *mesg_data, FIT_BOOL restore_fields)
|
185
|
+
{
|
186
|
+
FIT_UINT32 offset;
|
187
|
+
FIT_UINT8 size;
|
188
|
+
FIT_BYTE old_mesg[FIT_MESG_SIZE];
|
189
|
+
|
190
|
+
offset = Fit_GetFileMesgOffset(fit_ram_files[file]->file_def, mesg_num, 0);
|
191
|
+
size = Fit_GetMesgSize(mesg_num);
|
192
|
+
|
193
|
+
if (restore_fields)
|
194
|
+
{
|
195
|
+
FitRAM_FileReadBytes(file, file_index, offset, old_mesg, size);
|
196
|
+
FitConvert_RestoreFields(old_mesg);
|
197
|
+
}
|
198
|
+
|
199
|
+
FitRAM_FileWriteBytes(file, file_index, offset, mesg_data, size);
|
200
|
+
}
|
201
|
+
|
202
|
+
#endif // defined(FIT_RAM_INCLUDE)
|
203
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Dynastream Innovations 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 2013 Dynastream Innovations Inc.
|
11
|
+
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 8.10Release
|
14
|
+
// Tag = $Name: AKW8_100 $
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
18
|
+
|
19
|
+
|
20
|
+
#if !defined(FIT_RAM_H)
|
21
|
+
#define FIT_RAM_H
|
22
|
+
|
23
|
+
#include "fit_example.h"
|
24
|
+
|
25
|
+
#if defined(FIT_RAM_INCLUDE)
|
26
|
+
|
27
|
+
///////////////////////////////////////////////////////////////////////////////
|
28
|
+
// Public Function Prototypes
|
29
|
+
///////////////////////////////////////////////////////////////////////////////
|
30
|
+
|
31
|
+
FIT_RAM_FILE FitRAM_LookupFile(FIT_FILE file);
|
32
|
+
FIT_UINT32 FitRAM_GetFileSize(FIT_RAM_FILE file);
|
33
|
+
void FitRAM_FileReadBytes(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT32 file_offset, void *data, FIT_UINT32 data_size);
|
34
|
+
void FitRAM_FileWriteBytes(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT32 file_offset, const void *data, FIT_UINT32 data_size);
|
35
|
+
void FitRAM_FileWriteMesg(FIT_RAM_FILE file, FIT_UINT16 file_index, FIT_UINT16 mesg_num, const void *mesg_data, FIT_BOOL restore_fields);
|
36
|
+
|
37
|
+
#endif // defined(FIT_RAM_INCLUDE)
|
38
|
+
|
39
|
+
#endif // !defined(FIT_RAM_H)
|
data/ext/rubyfit/rubyfit.c
CHANGED
@@ -32,11 +32,13 @@ VALUE cFitHandlerUserProfileFun;
|
|
32
32
|
VALUE cFitHandlerEventFun;
|
33
33
|
VALUE cFitHandlerWeightScaleInfoFun;
|
34
34
|
static ID HANDLER_ATTR;
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
/*
|
36
|
+
* garmin/dynastream, decided to pinch pennies on bits by tinkering with well
|
37
|
+
* established time offsets. This is the magic number of seconds needed to add
|
38
|
+
* to their number to get the true number of seconds since the epoch.
|
39
|
+
* This is 20 years of seconds.
|
40
|
+
*/
|
41
|
+
const long GARMIN_TIME_OFFSET = 631065600;
|
40
42
|
|
41
43
|
|
42
44
|
void pass_message(char *msg) {
|
@@ -68,15 +70,15 @@ static VALUE init(VALUE self, VALUE handler) {
|
|
68
70
|
return Qnil;
|
69
71
|
}
|
70
72
|
|
71
|
-
static pass_activity(const FIT_ACTIVITY_MESG *mesg) {
|
73
|
+
static void pass_activity(const FIT_ACTIVITY_MESG *mesg) {
|
72
74
|
VALUE rh = rb_hash_new();
|
73
75
|
|
74
76
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
75
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
77
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
76
78
|
if(mesg->total_timer_time != FIT_UINT32_INVALID)
|
77
79
|
rb_hash_aset(rh, rb_str_new2("total_timer_time"), rb_float_new(mesg->total_timer_time / 1000.0));
|
78
80
|
if(mesg->local_timestamp != FIT_DATE_TIME_INVALID)
|
79
|
-
rb_hash_aset(rh, rb_str_new2("local_timestamp"), rb_float_new(mesg->local_timestamp +
|
81
|
+
rb_hash_aset(rh, rb_str_new2("local_timestamp"), rb_float_new(mesg->local_timestamp + GARMIN_TIME_OFFSET));
|
80
82
|
if(mesg->num_sessions != FIT_UINT16_INVALID)
|
81
83
|
rb_hash_aset(rh, rb_str_new2("num_sessions"), UINT2NUM(mesg->num_sessions));
|
82
84
|
if(mesg->type != FIT_ENUM_INVALID)
|
@@ -91,11 +93,11 @@ static pass_activity(const FIT_ACTIVITY_MESG *mesg) {
|
|
91
93
|
rb_funcall(cFitHandler, cFitHandlerActivityFun, 1, rh);
|
92
94
|
}
|
93
95
|
|
94
|
-
static pass_record(const FIT_RECORD_MESG *mesg) {
|
96
|
+
static void pass_record(const FIT_RECORD_MESG *mesg) {
|
95
97
|
VALUE rh = rb_hash_new();
|
96
98
|
|
97
99
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
98
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
100
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
99
101
|
if(mesg->position_lat != FIT_SINT32_INVALID)
|
100
102
|
rb_hash_aset(rh, rb_str_new2("position_lat"), fit_pos_to_rb(mesg->position_lat));
|
101
103
|
if(mesg->position_long != FIT_SINT32_INVALID)
|
@@ -126,13 +128,13 @@ static pass_record(const FIT_RECORD_MESG *mesg) {
|
|
126
128
|
rb_funcall(cFitHandler, cFitHandlerRecordFun, 1, rh);
|
127
129
|
}
|
128
130
|
|
129
|
-
static pass_lap(const FIT_LAP_MESG *mesg) {
|
131
|
+
static void pass_lap(const FIT_LAP_MESG *mesg) {
|
130
132
|
VALUE rh = rb_hash_new();
|
131
133
|
|
132
134
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
133
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
135
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
134
136
|
if(mesg->start_time != FIT_DATE_TIME_INVALID)
|
135
|
-
rb_hash_aset(rh, rb_str_new2("start_time"), UINT2NUM(mesg->start_time +
|
137
|
+
rb_hash_aset(rh, rb_str_new2("start_time"), UINT2NUM(mesg->start_time + GARMIN_TIME_OFFSET));
|
136
138
|
if(mesg->start_position_lat != FIT_SINT32_INVALID)
|
137
139
|
rb_hash_aset(rh, rb_str_new2("start_position_lat"), fit_pos_to_rb(mesg->start_position_lat));
|
138
140
|
if(mesg->start_position_long != FIT_SINT32_INVALID)
|
@@ -149,14 +151,6 @@ static pass_lap(const FIT_LAP_MESG *mesg) {
|
|
149
151
|
rb_hash_aset(rh, rb_str_new2("total_distance"), rb_float_new(mesg->total_distance / 100.0));
|
150
152
|
if(mesg->total_cycles != FIT_UINT32_INVALID)
|
151
153
|
rb_hash_aset(rh, rb_str_new2("total_cycles"), UINT2NUM(mesg->total_cycles));
|
152
|
-
if(mesg->nec_lat != FIT_SINT32_INVALID)
|
153
|
-
rb_hash_aset(rh, rb_str_new2("nec_lat"), fit_pos_to_rb(mesg->nec_lat));
|
154
|
-
if(mesg->nec_long != FIT_SINT32_INVALID)
|
155
|
-
rb_hash_aset(rh, rb_str_new2("nec_long"), fit_pos_to_rb(mesg->nec_long));
|
156
|
-
if(mesg->swc_lat != FIT_SINT32_INVALID)
|
157
|
-
rb_hash_aset(rh, rb_str_new2("swc_lat"), fit_pos_to_rb(mesg->swc_lat));
|
158
|
-
if(mesg->swc_long != FIT_SINT32_INVALID)
|
159
|
-
rb_hash_aset(rh, rb_str_new2("swc_long"), fit_pos_to_rb(mesg->swc_long));
|
160
154
|
if(mesg->message_index != FIT_UINT16_INVALID)
|
161
155
|
rb_hash_aset(rh, rb_str_new2("message_index"), UINT2NUM(mesg->message_index));
|
162
156
|
if(mesg->total_calories != FIT_UINT16_INVALID)
|
@@ -199,13 +193,13 @@ static pass_lap(const FIT_LAP_MESG *mesg) {
|
|
199
193
|
rb_funcall(cFitHandler, cFitHandlerLapFun, 1, rh);
|
200
194
|
}
|
201
195
|
|
202
|
-
static pass_session(const FIT_SESSION_MESG *mesg) {
|
196
|
+
static void pass_session(const FIT_SESSION_MESG *mesg) {
|
203
197
|
VALUE rh = rb_hash_new();
|
204
198
|
|
205
199
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
206
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
200
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
207
201
|
if(mesg->start_time != FIT_DATE_TIME_INVALID)
|
208
|
-
rb_hash_aset(rh, rb_str_new2("start_time"), UINT2NUM(mesg->start_time +
|
202
|
+
rb_hash_aset(rh, rb_str_new2("start_time"), UINT2NUM(mesg->start_time + GARMIN_TIME_OFFSET));
|
209
203
|
if(mesg->start_position_lat != FIT_SINT32_INVALID)
|
210
204
|
rb_hash_aset(rh, rb_str_new2("start_position_lat"), fit_pos_to_rb(mesg->start_position_lat));
|
211
205
|
if(mesg->start_position_long != FIT_SINT32_INVALID)
|
@@ -272,7 +266,7 @@ static pass_session(const FIT_SESSION_MESG *mesg) {
|
|
272
266
|
rb_funcall(cFitHandler, cFitHandlerSessionFun, 1, rh);
|
273
267
|
}
|
274
268
|
|
275
|
-
static pass_user_profile(const FIT_USER_PROFILE_MESG *mesg) {
|
269
|
+
static void pass_user_profile(const FIT_USER_PROFILE_MESG *mesg) {
|
276
270
|
VALUE rh = rb_hash_new();
|
277
271
|
|
278
272
|
if(mesg->friendly_name != FIT_STRING_INVALID)
|
@@ -317,11 +311,11 @@ static pass_user_profile(const FIT_USER_PROFILE_MESG *mesg) {
|
|
317
311
|
rb_funcall(cFitHandler, cFitHandlerUserProfileFun, 1, rh);
|
318
312
|
}
|
319
313
|
|
320
|
-
static pass_event(const FIT_EVENT_MESG *mesg) {
|
314
|
+
static void pass_event(const FIT_EVENT_MESG *mesg) {
|
321
315
|
VALUE rh = rb_hash_new();
|
322
316
|
|
323
317
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
324
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
318
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
325
319
|
if(mesg->data != FIT_UINT32_INVALID)
|
326
320
|
rb_hash_aset(rh, rb_str_new2("data"), UINT2NUM(mesg->data));
|
327
321
|
if(mesg->data16 != FIT_UINT16_INVALID)
|
@@ -336,11 +330,11 @@ static pass_event(const FIT_EVENT_MESG *mesg) {
|
|
336
330
|
rb_funcall(cFitHandler, cFitHandlerEventFun, 1, rh);
|
337
331
|
}
|
338
332
|
|
339
|
-
static pass_device_info(const FIT_DEVICE_INFO_MESG *mesg) {
|
333
|
+
static void pass_device_info(const FIT_DEVICE_INFO_MESG *mesg) {
|
340
334
|
VALUE rh = rb_hash_new();
|
341
335
|
|
342
336
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
343
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
337
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
344
338
|
if(mesg->serial_number != FIT_UINT32Z_INVALID)
|
345
339
|
rb_hash_aset(rh, rb_str_new2("serial_number"), UINT2NUM(mesg->serial_number));
|
346
340
|
if(mesg->manufacturer != FIT_MANUFACTURER_INVALID)
|
@@ -363,11 +357,11 @@ static pass_device_info(const FIT_DEVICE_INFO_MESG *mesg) {
|
|
363
357
|
rb_funcall(cFitHandler, cFitHandlerDeviceInfoFun, 1, rh);
|
364
358
|
}
|
365
359
|
|
366
|
-
static pass_weight_scale_info(const FIT_WEIGHT_SCALE_MESG *mesg) {
|
360
|
+
static void pass_weight_scale_info(const FIT_WEIGHT_SCALE_MESG *mesg) {
|
367
361
|
VALUE rh = rb_hash_new();
|
368
362
|
|
369
363
|
if(mesg->timestamp != FIT_DATE_TIME_INVALID)
|
370
|
-
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp +
|
364
|
+
rb_hash_aset(rh, rb_str_new2("timestamp"), UINT2NUM(mesg->timestamp + GARMIN_TIME_OFFSET));
|
371
365
|
if(mesg->weight != FIT_WEIGHT_INVALID)
|
372
366
|
rb_hash_aset(rh, rb_str_new2("weight"), rb_float_new(mesg->weight / 100.0));
|
373
367
|
if(mesg->percent_fat != FIT_UINT16_INVALID)
|
@@ -403,7 +397,6 @@ static VALUE parse(VALUE self, VALUE original_str) {
|
|
403
397
|
FIT_UINT8 buf[8];
|
404
398
|
FIT_CONVERT_RETURN convert_return = FIT_CONVERT_CONTINUE;
|
405
399
|
FIT_UINT32 buf_size;
|
406
|
-
FIT_UINT32 mesg_index = 0;
|
407
400
|
#if defined(FIT_CONVERT_MULTI_THREAD)
|
408
401
|
FIT_CONVERT_STATE state;
|
409
402
|
#endif
|
@@ -444,13 +437,10 @@ static VALUE parse(VALUE self, VALUE original_str) {
|
|
444
437
|
FIT_UINT16 mesg_num = FitConvert_GetMessageNumber();
|
445
438
|
#endif
|
446
439
|
|
447
|
-
//sprintf(err_msg, "Mesg %d (%d) - ", mesg_index++, mesg_num);
|
448
440
|
//pass_message(err_msg);
|
449
441
|
|
450
442
|
switch(mesg_num) {
|
451
443
|
case FIT_MESG_NUM_FILE_ID: {
|
452
|
-
const FIT_FILE_ID_MESG *id = (FIT_FILE_ID_MESG *) mesg;
|
453
|
-
//sprintf(err_msg, "File ID: type=%u, number=%u\n", id->type, id->number);
|
454
444
|
//pass_message(err_msg);
|
455
445
|
break;
|
456
446
|
}
|
@@ -578,7 +568,6 @@ static VALUE parse(VALUE self, VALUE original_str) {
|
|
578
568
|
void Init_rubyfit() {
|
579
569
|
mRubyFit = rb_define_module("RubyFit");
|
580
570
|
cFitParser = rb_define_class_under(mRubyFit, "FitParser", rb_cObject);
|
581
|
-
//cFitParser = rb_define_class("FitParser", rb_cObject);
|
582
571
|
|
583
572
|
//instance methods
|
584
573
|
rb_define_method(cFitParser, "initialize", init, 1);
|
data/lib/rubyfit/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyfit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Cullen King
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: FIT files are binary, and as a result, are a pain to parse. This is
|
15
14
|
a wrapper around the FIT SDK, which makes creating a stream based parser simple.
|
@@ -22,42 +21,41 @@ extra_rdoc_files: []
|
|
22
21
|
files:
|
23
22
|
- lib/rubyfit/version.rb
|
24
23
|
- lib/rubyfit.rb
|
25
|
-
- ext/rubyfit/fit_convert.c
|
26
|
-
- ext/rubyfit/rubyfit.c
|
27
24
|
- ext/rubyfit/fit.c
|
25
|
+
- ext/rubyfit/fit_convert.c
|
28
26
|
- ext/rubyfit/fit_crc.c
|
29
|
-
- ext/rubyfit/
|
30
|
-
- ext/rubyfit/
|
27
|
+
- ext/rubyfit/fit_example.c
|
28
|
+
- ext/rubyfit/fit_ram.c
|
29
|
+
- ext/rubyfit/rubyfit.c
|
31
30
|
- ext/rubyfit/fit.h
|
31
|
+
- ext/rubyfit/fit_config.h
|
32
32
|
- ext/rubyfit/fit_convert.h
|
33
33
|
- ext/rubyfit/fit_crc.h
|
34
|
-
- ext/rubyfit/
|
35
|
-
- ext/rubyfit/
|
36
|
-
- ext/rubyfit/fit_product.h
|
34
|
+
- ext/rubyfit/fit_example.h
|
35
|
+
- ext/rubyfit/fit_ram.h
|
37
36
|
- ext/rubyfit/extconf.rb
|
38
37
|
homepage: http://cullenking.com
|
39
38
|
licenses: []
|
39
|
+
metadata: {}
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|
43
43
|
- lib
|
44
44
|
- ext
|
45
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
none: false
|
47
46
|
requirements:
|
48
|
-
- -
|
47
|
+
- - '>='
|
49
48
|
- !ruby/object:Gem::Version
|
50
49
|
version: '0'
|
51
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
51
|
requirements:
|
54
|
-
- -
|
52
|
+
- - '>='
|
55
53
|
- !ruby/object:Gem::Version
|
56
54
|
version: '0'
|
57
55
|
requirements: []
|
58
56
|
rubyforge_project: rubyfit
|
59
|
-
rubygems_version:
|
57
|
+
rubygems_version: 2.0.5
|
60
58
|
signing_key:
|
61
|
-
specification_version:
|
59
|
+
specification_version: 4
|
62
60
|
summary: A stream based parser for FIT files.
|
63
61
|
test_files: []
|