fit-file-parser 2.3.0 → 2.3.1
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.
- package/dist/binary.js +8 -1
- package/dist/cjs/binary.js +8 -1
- package/inspect_parser.ts +34 -0
- package/output.txt +154 -0
- package/package.json +1 -1
package/dist/binary.js
CHANGED
|
@@ -5,6 +5,7 @@ const CompressedLocalMsgNumMask = 0x60;
|
|
|
5
5
|
const CompressedHeaderMask = 0x80;
|
|
6
6
|
const GarminTimeOffset = 631065600000;
|
|
7
7
|
let monitoring_timestamp = 0;
|
|
8
|
+
console.log(">>> LOADING BINARY.TS <<<");
|
|
8
9
|
export function addEndian(littleEndian, bytes) {
|
|
9
10
|
let result = 0;
|
|
10
11
|
if (!littleEndian)
|
|
@@ -106,7 +107,13 @@ function formatByType(data, type, scale, offset) {
|
|
|
106
107
|
case 'uint16_array':
|
|
107
108
|
case 'uint8_array':
|
|
108
109
|
if (Array.isArray(data)) {
|
|
109
|
-
|
|
110
|
+
const baseType = type.replace('_array', '');
|
|
111
|
+
return data.map((dataItem) => {
|
|
112
|
+
if (isInvalidValue(dataItem, baseType)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return scale ? dataItem / scale + offset : dataItem;
|
|
116
|
+
});
|
|
110
117
|
}
|
|
111
118
|
return scale ? data / scale + offset : data;
|
|
112
119
|
default:
|
package/dist/cjs/binary.js
CHANGED
|
@@ -11,6 +11,7 @@ const CompressedLocalMsgNumMask = 0x60;
|
|
|
11
11
|
const CompressedHeaderMask = 0x80;
|
|
12
12
|
const GarminTimeOffset = 631065600000;
|
|
13
13
|
let monitoring_timestamp = 0;
|
|
14
|
+
console.log(">>> LOADING BINARY.TS <<<");
|
|
14
15
|
function addEndian(littleEndian, bytes) {
|
|
15
16
|
let result = 0;
|
|
16
17
|
if (!littleEndian)
|
|
@@ -112,7 +113,13 @@ function formatByType(data, type, scale, offset) {
|
|
|
112
113
|
case 'uint16_array':
|
|
113
114
|
case 'uint8_array':
|
|
114
115
|
if (Array.isArray(data)) {
|
|
115
|
-
|
|
116
|
+
const baseType = type.replace('_array', '');
|
|
117
|
+
return data.map((dataItem) => {
|
|
118
|
+
if (isInvalidValue(dataItem, baseType)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return scale ? dataItem / scale + offset : dataItem;
|
|
122
|
+
});
|
|
116
123
|
}
|
|
117
124
|
return scale ? data / scale + offset : data;
|
|
118
125
|
default:
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import FitParser from './src/fit-parser';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
|
|
5
|
+
const filePath = 'examples/road-with-power.fit';
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
try {
|
|
9
|
+
const content = fs.readFileSync(filePath);
|
|
10
|
+
const parser = new FitParser({
|
|
11
|
+
force: true,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
parser.parse(content, (error: any, data: any) => {
|
|
15
|
+
if (error) {
|
|
16
|
+
console.error(error);
|
|
17
|
+
} else {
|
|
18
|
+
console.log('Parsed successfully');
|
|
19
|
+
// Check sessions for power zone data
|
|
20
|
+
if (data.sessions && data.sessions.length > 0) {
|
|
21
|
+
const session = data.sessions[0];
|
|
22
|
+
console.log('Session keys:', Object.keys(session));
|
|
23
|
+
console.log('time_in_power_zone:', session.time_in_power_zone);
|
|
24
|
+
console.log('time_in_hr_zone:', session.time_in_hr_zone);
|
|
25
|
+
console.log('time_in_speed_zone:', session.time_in_speed_zone);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
run();
|
package/output.txt
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
>>> LOADING BINARY.TS <<<
|
|
2
|
+
[DEBUG] Session field: 253 (timestamp), Type: date_time, Data: 1137663486
|
|
3
|
+
[DEBUG] Session field: 2 (start_time), Type: date_time, Data: 1137663486
|
|
4
|
+
[DEBUG] Session field: 3 (start_position_lat), Type: sint32, Data: 472983081
|
|
5
|
+
[DEBUG] Session field: 4 (start_position_long), Type: sint32, Data: 250374956
|
|
6
|
+
[DEBUG] Session field: 7 (total_elapsed_time), Type: uint32, Data: 14455786
|
|
7
|
+
[DEBUG] Session field: 8 (total_timer_time), Type: uint32, Data: 14455786
|
|
8
|
+
[DEBUG] Session field: 9 (total_distance), Type: uint32, Data: 3628685
|
|
9
|
+
[DEBUG] Session field: 10 (total_cycles), Type: uint32, Data: 4294967295
|
|
10
|
+
[DEBUG] Session field: 29 (nec_lat), Type: sint32, Data: 473011054
|
|
11
|
+
[DEBUG] Session field: 30 (nec_long), Type: sint32, Data: 250518365
|
|
12
|
+
[DEBUG] Session field: 31 (swc_lat), Type: sint32, Data: 472847023
|
|
13
|
+
[DEBUG] Session field: 32 (swc_long), Type: sint32, Data: 250368555
|
|
14
|
+
[DEBUG] Session field: 38 (end_position_lat), Type: sint32, Data: 472990941
|
|
15
|
+
[DEBUG] Session field: 39 (end_position_long), Type: sint32, Data: 250515862
|
|
16
|
+
[DEBUG] Session field: 48 (total_work), Type: uint32, Data: 4294967295
|
|
17
|
+
[DEBUG] Session field: 110 (sport_profile_name), Type: string, Data: DOWNHILL MTB
|
|
18
|
+
[DEBUG] Session field: 112 (time_standing), Type: uint32, Data: 4294967295
|
|
19
|
+
[DEBUG] Session field: 116 (avg_left_power_phase), Type: uint8, Data: 255
|
|
20
|
+
[DEBUG] Session field: 117 (avg_left_power_phase_peak), Type: uint8, Data: 255
|
|
21
|
+
[DEBUG] Session field: 118 (avg_right_power_phase), Type: uint8, Data: 255
|
|
22
|
+
[DEBUG] Session field: 119 (avg_right_power_phase_peak), Type: uint8, Data: 255
|
|
23
|
+
[DEBUG] Session field: 120 (avg_power_position), Type: uint16, Data: 65535
|
|
24
|
+
[DEBUG] Session field: 121 (max_power_position), Type: uint16, Data: 65535
|
|
25
|
+
[DEBUG] Session field: 124 (enhanced_avg_speed), Type: uint32, Data: 2510
|
|
26
|
+
[DEBUG] Session field: 125 (enhanced_max_speed), Type: uint32, Data: 11561
|
|
27
|
+
[DEBUG] Session field: 168 (training_load_peak), Type: uint32, Data: 10061199
|
|
28
|
+
[DEBUG] Session field: 181 (total_grit), Type: float32, Data: 180.6374969482422
|
|
29
|
+
[DEBUG] Session field: 187 (avg_flow), Type: float32, Data: 5.879695892333984
|
|
30
|
+
[DEBUG] Session field: 203 (undefined), Type: undefined, Data: 4294967295
|
|
31
|
+
[DEBUG] Session field: 224 (undefined), Type: undefined, Data: 2147483647
|
|
32
|
+
[DEBUG] Session field: 225 (undefined), Type: undefined, Data: 2147483647
|
|
33
|
+
[DEBUG] Session field: 226 (undefined), Type: undefined, Data: 2147483647
|
|
34
|
+
[DEBUG] Session field: 229 (undefined), Type: undefined, Data: 4294967295
|
|
35
|
+
[DEBUG] Session field: 254 (message_index), Type: message_index, Data: 0
|
|
36
|
+
[DEBUG] Session field: 11 (total_calories), Type: uint16, Data: 1215
|
|
37
|
+
[DEBUG] Session field: 13 (total_fat_calories), Type: uint16, Data: 65535
|
|
38
|
+
[DEBUG] Session field: 20 (avg_power), Type: uint16, Data: 65535
|
|
39
|
+
[DEBUG] Session field: 21 (max_power), Type: uint16, Data: 65535
|
|
40
|
+
[DEBUG] Session field: 22 (total_ascent), Type: uint16, Data: 1633
|
|
41
|
+
[DEBUG] Session field: 23 (total_descent), Type: uint16, Data: 1880
|
|
42
|
+
[DEBUG] Session field: 25 (first_lap_index), Type: uint16, Data: 0
|
|
43
|
+
[DEBUG] Session field: 26 (num_laps), Type: uint16, Data: 1
|
|
44
|
+
[DEBUG] Session field: 34 (normalized_power), Type: uint16, Data: 65535
|
|
45
|
+
[DEBUG] Session field: 35 (training_stress_score), Type: uint16, Data: 65535
|
|
46
|
+
[DEBUG] Session field: 36 (intensity_factor), Type: uint16, Data: 65535
|
|
47
|
+
[DEBUG] Session field: 37 (left_right_balance), Type: left_right_balance_100, Data: 65535
|
|
48
|
+
[DEBUG] Session field: 45 (threshold_power), Type: uint16, Data: 65535
|
|
49
|
+
[DEBUG] Session field: 106 (undefined), Type: undefined, Data: 0
|
|
50
|
+
[DEBUG] Session field: 107 (undefined), Type: undefined, Data: 65535
|
|
51
|
+
[DEBUG] Session field: 108 (undefined), Type: undefined, Data: 178
|
|
52
|
+
[DEBUG] Session field: 113 (stand_count), Type: uint16, Data: 65535
|
|
53
|
+
[DEBUG] Session field: 139 (avg_vam), Type: uint16, Data: 189
|
|
54
|
+
[DEBUG] Session field: 151 (undefined), Type: undefined, Data: 65535
|
|
55
|
+
[DEBUG] Session field: 169 (enhanced_avg_respiration_rate), Type: uint16, Data: 2295
|
|
56
|
+
[DEBUG] Session field: 170 (enhanced_max_respiration_rate), Type: uint16, Data: 4511
|
|
57
|
+
[DEBUG] Session field: 177 (undefined), Type: undefined, Data: 65535
|
|
58
|
+
[DEBUG] Session field: 178 (est_sweat_loss), Type: uint16, Data: 1455
|
|
59
|
+
[DEBUG] Session field: 179 (undefined), Type: undefined, Data: 65535
|
|
60
|
+
[DEBUG] Session field: 180 (enhanced_min_respiration_rate), Type: uint16, Data: 1040
|
|
61
|
+
[DEBUG] Session field: 183 (jump_count), Type: uint16, Data: 129
|
|
62
|
+
[DEBUG] Session field: 196 (resting_calories), Type: uint16, Data: 317
|
|
63
|
+
[DEBUG] Session field: 204 (undefined), Type: undefined, Data: 65535
|
|
64
|
+
[DEBUG] Session field: 0 (event), Type: event, Data: 8
|
|
65
|
+
[DEBUG] Session field: 1 (event_type), Type: event_type, Data: 1
|
|
66
|
+
[DEBUG] Session field: 5 (sport), Type: sport, Data: 2
|
|
67
|
+
[DEBUG] Session field: 6 (sub_sport), Type: sub_sport, Data: 9
|
|
68
|
+
[DEBUG] Session field: 16 (avg_heart_rate), Type: uint8, Data: 108
|
|
69
|
+
[DEBUG] Session field: 17 (max_heart_rate), Type: uint8, Data: 179
|
|
70
|
+
[DEBUG] Session field: 18 (avg_cadence), Type: uint8, Data: 255
|
|
71
|
+
[DEBUG] Session field: 19 (max_cadence), Type: uint8, Data: 255
|
|
72
|
+
[DEBUG] Session field: 24 (total_training_effect), Type: uint8, Data: 31
|
|
73
|
+
[DEBUG] Session field: 27 (event_group), Type: uint8, Data: 255
|
|
74
|
+
[DEBUG] Session field: 28 (trigger), Type: session_trigger, Data: 0
|
|
75
|
+
[DEBUG] Session field: 57 (avg_temperature), Type: sint8, Data: 8
|
|
76
|
+
[DEBUG] Session field: 58 (max_temperature), Type: sint8, Data: 16
|
|
77
|
+
[DEBUG] Session field: 81 (undefined), Type: undefined, Data: 0
|
|
78
|
+
[DEBUG] Session field: 92 (avg_fractional_cadence), Type: uint8, Data: 255
|
|
79
|
+
[DEBUG] Session field: 93 (max_fractional_cadence), Type: uint8, Data: 255
|
|
80
|
+
[DEBUG] Session field: 94 (total_fractional_cycles), Type: uint8, Data: 255
|
|
81
|
+
[DEBUG] Session field: 101 (avg_left_torque_effectiveness), Type: uint8, Data: 255
|
|
82
|
+
[DEBUG] Session field: 102 (avg_right_torque_effectiveness), Type: uint8, Data: 255
|
|
83
|
+
[DEBUG] Session field: 103 (avg_left_pedal_smoothness), Type: uint8, Data: 255
|
|
84
|
+
[DEBUG] Session field: 104 (avg_right_pedal_smoothness), Type: uint8, Data: 255
|
|
85
|
+
[DEBUG] Session field: 105 (avg_combined_pedal_smoothness), Type: uint8, Data: 255
|
|
86
|
+
[DEBUG] Session field: 109 (undefined), Type: undefined, Data: 255
|
|
87
|
+
[DEBUG] Session field: 111 (sport_index), Type: uint8, Data: 255
|
|
88
|
+
[DEBUG] Session field: 114 (avg_left_pco), Type: sint8, Data: 127
|
|
89
|
+
[DEBUG] Session field: 115 (avg_right_pco), Type: sint8, Data: 127
|
|
90
|
+
[DEBUG] Session field: 122 (avg_cadence_position), Type: uint8, Data: 255
|
|
91
|
+
[DEBUG] Session field: 123 (max_cadence_position), Type: uint8, Data: 255
|
|
92
|
+
[DEBUG] Session field: 137 (total_anaerobic_training_effect), Type: uint8, Data: 31
|
|
93
|
+
[DEBUG] Session field: 138 (undefined), Type: undefined, Data: 8
|
|
94
|
+
[DEBUG] Session field: 150 (min_temperature), Type: sint8, Data: 4
|
|
95
|
+
[DEBUG] Session field: 184 (undefined), Type: undefined, Data: 0
|
|
96
|
+
[DEBUG] Session field: 185 (undefined), Type: undefined, Data: 255
|
|
97
|
+
[DEBUG] Session field: 188 (primary_benefit), Type: uint8, Data: 6
|
|
98
|
+
[DEBUG] Session field: 192 (workout_feel), Type: uint8, Data: 255
|
|
99
|
+
[DEBUG] Session field: 193 (workout_rpe), Type: uint8, Data: 255
|
|
100
|
+
[DEBUG] Session field: 202 (undefined), Type: undefined, Data: 255
|
|
101
|
+
[DEBUG] Session field: 205 (undefined), Type: undefined, Data: 255
|
|
102
|
+
[DEBUG] Session field: 206 (undefined), Type: undefined, Data: 255
|
|
103
|
+
[DEBUG] Session field: 207 (undefined), Type: undefined, Data: 255
|
|
104
|
+
[DEBUG] Session field: 219 (undefined), Type: undefined, Data: 45
|
|
105
|
+
Parsed successfully
|
|
106
|
+
Session keys: [
|
|
107
|
+
'timestamp',
|
|
108
|
+
'start_time',
|
|
109
|
+
'start_position_lat',
|
|
110
|
+
'start_position_long',
|
|
111
|
+
'total_elapsed_time',
|
|
112
|
+
'total_timer_time',
|
|
113
|
+
'total_distance',
|
|
114
|
+
'nec_lat',
|
|
115
|
+
'nec_long',
|
|
116
|
+
'swc_lat',
|
|
117
|
+
'swc_long',
|
|
118
|
+
'end_position_lat',
|
|
119
|
+
'end_position_long',
|
|
120
|
+
'sport_profile_name',
|
|
121
|
+
'enhanced_avg_speed',
|
|
122
|
+
'enhanced_max_speed',
|
|
123
|
+
'training_load_peak',
|
|
124
|
+
'total_grit',
|
|
125
|
+
'avg_flow',
|
|
126
|
+
'message_index',
|
|
127
|
+
'total_calories',
|
|
128
|
+
'total_ascent',
|
|
129
|
+
'total_descent',
|
|
130
|
+
'first_lap_index',
|
|
131
|
+
'num_laps',
|
|
132
|
+
'left_right_balance',
|
|
133
|
+
'avg_vam',
|
|
134
|
+
'enhanced_avg_respiration_rate',
|
|
135
|
+
'enhanced_max_respiration_rate',
|
|
136
|
+
'est_sweat_loss',
|
|
137
|
+
'enhanced_min_respiration_rate',
|
|
138
|
+
'jump_count',
|
|
139
|
+
'resting_calories',
|
|
140
|
+
'event',
|
|
141
|
+
'event_type',
|
|
142
|
+
'sport',
|
|
143
|
+
'sub_sport',
|
|
144
|
+
'avg_heart_rate',
|
|
145
|
+
'max_heart_rate',
|
|
146
|
+
'total_training_effect',
|
|
147
|
+
'trigger',
|
|
148
|
+
'avg_temperature',
|
|
149
|
+
'max_temperature',
|
|
150
|
+
'total_anaerobic_training_effect',
|
|
151
|
+
'min_temperature',
|
|
152
|
+
'primary_benefit'
|
|
153
|
+
]
|
|
154
|
+
time_in_power_zone: undefined
|