Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/fit4ruby/Activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ def check
# broken. Unfortunately, the Skiing/Boarding app in the Fenix3
# produces such broken FIT files. So we just warn about this
# problem and discard the earlier records.
Log.error "Record #{r.timestamp} has smaller distance " +
Log.error "- #{r.timestamp} has smaller distance " +
"(#{r.distance}) than an earlier record (#{distance})."
# Index of the list record to be discarded.
(idx - 1).downto(0) do |i|
if (ri = @records[i]).distance > r.distance
ri = @records[i]
if ri.distance && (ri.distance > r.distance)
# This is just an approximation. It looks like the app adds
# records to the FIT file for runs that it meant to discard.
# Maybe the two successive time start events are a better
Expand Down
15 changes: 8 additions & 7 deletions lib/fit4ruby/CRC16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
module Fit4Ruby

module CRC16


@@crc_table = [
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
]
def write_crc(io, start_pos, end_pos)
# Compute the checksum over the data section of the file and append it
# to the file. Ideally, we should compute the CRC from data in memory
Expand All @@ -27,10 +31,7 @@ def write_crc(io, start_pos, end_pos)
end

def compute_crc(io, start_pos, end_pos)
crc_table = [
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
]


io.seek(start_pos)

Expand All @@ -43,9 +44,9 @@ def compute_crc(io, start_pos, end_pos)
byte = io.readbyte

0.upto(1) do |i|
tmp = crc_table[crc & 0xF]
tmp = @@crc_table[crc & 0xF]
crc = (crc >> 4) & 0x0FFF
crc = crc ^ tmp ^ crc_table[(byte >> (4 * i)) & 0xF]
crc = crc ^ tmp ^ @@crc_table[(byte >> (4 * i)) & 0xF]
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/fit4ruby/DeviceInfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def check(index)
Log.fatal 'device info record 0 must have a product field set'
end
end
if @serial_number.nil?
Log.fatal 'device info record 0 must have a serial number set'
end
#if @serial_number.nil?
# Log.fatal 'device info record 0 must have a serial number set'
#end
end
end

Expand Down
124 changes: 121 additions & 3 deletions lib/fit4ruby/GlobalFitDictionaries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,51 +308,170 @@ module Fit4Ruby
entry 144, 'uint64z'

dict 'garmin_product'
entry 1,'hrm1'
entry 2,'axh01'
entry 3,'axb01'
entry 4,'axb02'
entry 6,'dsi_alf02'
entry 7,'hrm3ss'
entry 8, 'hrm_run_single_byte_product_id'
entry 9, 'bsm'
entry 10, 'bcm'
entry 11, 'axs01'
entry 12, 'hrm_tri_single_byte_product_id'
entry 14, 'fr225_single_byte_product_id'
entry 473, 'fr301_china'
entry 474, 'fr301_japan'
entry 475, 'fr301_korea'
entry 494, 'fr301_taiwan'
entry 717, 'fr405'
entry 782, 'fr50'
entry 987, 'fr405_japan'
entry 988, 'fr60'
entry 1011, 'dsi_alf01'
entry 1018, 'fr310xt'
entry 1036, 'edge500'
entry 1124, 'fr110'
entry 1169, 'edge800'
entry 1199, 'edge500_taiwan'
entry 1213, 'edge500_japan'
entry 1253, 'chirp'
entry 1274, 'fr110_japan'
entry 1325, 'edge200'
entry 1328, 'fr910xt'
entry 1333, 'edge800_taiwan'
entry 1334, 'edge800_japan'
entry 1341, 'alf04'
entry 1345, 'fr610'
entry 1360, 'fr210_japan'
entry 1380, 'vector_ss'
entry 1381, 'vector_cp'
entry 1386, 'edge800_china'
entry 1387, 'edge500_china'
entry 1410, 'fr610_japan'
entry 1422, 'edge500_korea'
entry 1436, 'fr70'
entry 1446, 'fr310xt_4t'
entry 1461, 'amx'
entry 1482, 'fr10'
entry 1497, 'edge800_korea'
entry 1499, 'swim'
entry 1537, 'fr910xt_china'
entry 1551, 'fenix'
entry 1555, 'edge200_taiwan'
entry 1561, 'edge510'
entry 1567, 'edge810'
entry 1570, 'tempe'
entry 1600, 'fr910xt_japan'
# The Fenix3 is rumored to have a Mediatek MT3333 GPS chipset. Not sure if
# that would be a beter name.
entry 1620, 'fenix3_gps' # Just a guess
entry 1621, 'fenix5_gps' # Just a guess
entry 1623, 'fr620'
entry 1632, 'fr220'
entry 1664, 'fr910xt_korea'
entry 1688, 'fr10_japan'
# The FR620 is rumored to have a MediaTek MT3339 GPS chipset while the
# FR920XT is rumored to have a MT3333. Not sure why they have the same ID
# in the FIT file for the GPS device.
entry 1689, 'fr620_fr920xt_gps' # Just a guess
entry 1721, 'edge810_japan'
entry 1735, 'virb_elite'
entry 1736, 'edge_touring'
entry 1742, 'edge510_japan'
entry 1743, 'hrm_tri'
entry 1752, 'hrm_run'
entry 1765, 'fr920xt'
entry 1821, 'edge510_asia'
entry 1822, 'edge810_china'
entry 1823, 'edge810_taiwan'
entry 1836, 'edge1000'
entry 1837, 'vivo_fit'
entry 1853, 'virb_remote'
entry 1885, 'vivo_ki'
entry 1903, 'fr15'
entry 1907, 'vivo_active'
entry 1918, 'edge510_korea'
entry 1928, 'fr620_japan'
entry 1929, 'fr620_china'
entry 1930, 'fr220_japan'
entry 1931, 'fr220_china'
entry 1936, 'approach_s6'
entry 1956, 'vivo_smart'
entry 1967, 'fenix2'
entry 1988, 'epix'
entry 2050, 'fenix3'
entry 2052, 'edge1000_taiwan'
entry 2053, 'edge1000_japan'
entry 2061, 'fr15_japan'
entry 2067, 'edge520'
entry 2070, 'edge1000_china'
entry 2072, 'fr620_russia'
entry 2073, 'fr220_russia'
entry 2079, 'vector_s'
entry 2100, 'edge1000_korea'
entry 2130, 'fr920xt_taiwan'
entry 2131, 'fr920xt_china'
entry 2132, 'fr920xt_japan'
entry 2134, 'virbx'
entry 2135, 'vivo_smart_apac'
entry 2140, 'etrex_touch'
entry 2147, 'edge25'
entry 2148, 'fr25'
entry 2150, 'vivo_fit2'
entry 2153, 'fr225'
entry 2156, 'fr630'
entry 2157, 'fr230'
entry 2160, 'vivo_active_apac'
entry 2161, 'vector_2'
entry 2162, 'vector_2s'
entry 2172, 'virbxe'
entry 2173, 'fr620_taiwan'
entry 2174, 'fr220_taiwan'
entry 2175, 'truswing'
entry 2188, 'fenix3_china'
entry 2189, 'fenix3_twn'
entry 2192, 'varia_headlight'
entry 2193, 'varia_taillight_old'
entry 2204, 'edge_explore_1000'
entry 2219, 'fr225_asia'
entry 2225, 'varia_radar_taillight'
entry 2226, 'varia_radar_display'
entry 2238, 'edge20'
entry 2266, 'd2_bravo'
entry 2262, 'approach_s20'
entry 2276, 'varia_remote'
entry 2327, 'hrm4_run'
entry 2337, 'vivo_active_hr'
entry 2347, 'vivo_smart_gps_hr'
entry 2348, 'vivo_smart_hr'
entry 2368, 'vivo_move'
entry 2398,'varia_vision'
entry 2406, 'vivo_fit3'
entry 2413, 'fenix3_hr'
entry 2417, 'virb_ultra_30'
entry 2429, 'index_smart_scale'
entry 2431, 'fr235'
entry 2432, 'fenix3_chronos'
entry 2441, 'oregon7xx'
entry 2444, 'rino7xx'
entry 2496, 'nautix'
entry 2530, 'edge_820'
entry 2531, 'edge_explore_820'
entry 2544, 'fenix5s'
entry 2604, 'fenix5x'
entry 2547, 'd2_bravo_titanium'
entry 2567, 'varia_ut800'
entry 2593, 'running_dynamics_pod'
entry 2604, 'fenix5x'
entry 2606, 'vivo_fit_jr'
entry 2691, 'fr935'
entry 2697, 'fenix5'
entry 2957, 'fenix5_gps_galileo' # Just a guess
entry 3111, 'fenix5x_plus'
entry 3111, 'fenix5x_plus' #Not included in the fit specifitation
entry 10007, 'sdm4'
entry 10014, 'edge_remote'
entry 20119, 'training_center'
entry 65531, 'connectiq_simulator'
entry 65532, 'android_antplus_plugin'
entry 65534, 'connect'

Expand Down Expand Up @@ -670,4 +789,3 @@ module Fit4Ruby
end

end

4 changes: 3 additions & 1 deletion lib/fit4ruby/GlobalFitMessage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ def alt_field(number, ref_field, &block)

def register_field_by_name(field, name)
if @fields_by_name.include?(name)
raise "Field '#{name}' has already been defined"
#raise "Field '#{name}' has already been defined"
Log.warn "Field '#{name}' has already been defined"
return
end

@fields_by_name[name] = field
Expand Down
Loading