python: missing base type in Profile["types"]

In a Python program I need to know the base type of the fields in the record messages, but the `Profile["types"]` dictionary is missing the data from the "Base Type" column.

Unfortunately adding the type in the `types` dict will break compatibility; is there any plan for adding the type information?

A possible solution is to add a new dict `base_type`, in addition to `version`, `common_fields`, `messages`, `types`, `mesg_num`.

Thanks

Manlio Perillo

  • The Profile["types"] dictionary is meant to contain the custom enum types, not the base types. The data type of every field can be found in the Profile['messages'] dictionary, and the base type information that is needed to decode files can be found in fit.py.

    The Profile['messages'] dictionary is keyed by message and field ids, because that is what is needed to efficiently decode files. But the values contained in the dictionary could be searched to find entries that match a message or field name. This would allow for the base type of a field to be looked up.

    The message definitions, including the types of each field, can also be found in the Profile.xlsx file that is included with the SDK when you download it from https://developer.garmin.com/fit/download/  

  • Unfortunately, I need the base type after the FIT file has been decoded.

    One example is the type "left_right_balance" for the record field "left_right_balance".  I would like to find that the base type is "uint8".

    Thanks.

  • The data types for the custom enums can be found in Profile.xlsx. There are 179, but you probably won't see more than a dozen used in an Activity file. In the Record message there are five fields that are custom types, but date_time and left_right_balance are the only two that are used.

    In Profile.xlsx I sorted the Types worksheet by column A, to separate the types from the values, and then use the concat function to generate this dictionary. It should be close, but check my work. There are no plans to add this to the SDK, but you can add this to your project. The 'enum' types will be uint8.

    dictionary = {
    'activity':'enum',
    'activity_class':'enum',
    'activity_level':'enum',
    'activity_subtype':'enum',
    'activity_type':'enum',
    'analog_watchface_layout':'enum',
    'ant_channel_id':'uint32z',
    'ant_network':'enum',
    'antplus_device_type':'uint8',
    'attitude_stage':'enum',
    'attitude_validity':'uint16',
    'auto_activity_detect':'uint32',
    'auto_sync_frequency':'enum',
    'autolap_trigger':'enum',
    'autoscroll':'enum',
    'backlight_mode':'enum',
    'backlight_timeout':'uint8',
    'battery_status':'uint8',
    'bench_press_exercise_name':'uint16',
    'bike_light_beam_angle_mode':'uint8',
    'bike_light_network_config_type':'enum',
    'ble_device_type':'uint8',
    'body_location':'enum',
    'bp_status':'enum',
    'calf_raise_exercise_name':'uint16',
    'camera_event_type':'enum',
    'camera_orientation_type':'enum',
    'cardio_exercise_name':'uint16',
    'carry_exercise_name':'uint16',
    'ccr_setpoint_switch_mode':'enum',
    'checksum':'uint8',
    'chop_exercise_name':'uint16',
    'climb_pro_event':'enum',
    'comm_timeout_type':'uint16',
    'connectivity_capabilities':'uint32z',
    'core_exercise_name':'uint16',
    'course_capabilities':'uint32z',
    'course_point':'enum',
    'crunch_exercise_name':'uint16',
    'curl_exercise_name':'uint16',
    'date_mode':'enum',
    'date_time':'uint32',
    'day_of_week':'enum',
    'deadlift_exercise_name':'uint16',
    'device_index':'uint8',
    'digital_watchface_layout':'enum',
    'display_heart':'enum',
    'display_measure':'enum',
    'display_orientation':'enum',
    'display_position':'enum',
    'display_power':'enum',
    'dive_alarm_type':'enum',
    'dive_alert':'enum',
    'dive_backlight_mode':'enum',
    'dive_gas_mode':'enum',
    'dive_gas_status':'enum',
    'event':'enum',
    'event_type':'enum',
    'exd_data_units':'enum',
    'exd_descriptors':'enum',
    'exd_display_type':'enum',
    'exd_layout':'enum',
    'exd_qualifiers':'enum',
    'exercise_category':'uint16',
    'favero_product':'uint16',
    'file':'enum',
    'file_flags':'uint8z',
    'fit_base_type':'uint8',
    'fit_base_unit':'uint16',
    'fitness_equipment_state':'enum',
    'flye_exercise_name':'uint16',
    'garmin_product':'uint16',
    'gas_consumption_rate_type':'enum',
    'gender':'enum',
    'goal':'enum',
    'goal_recurrence':'enum',
    'goal_source':'enum',
    'hip_raise_exercise_name':'uint16',
    'hip_stability_exercise_name':'uint16',
    'hip_swing_exercise_name':'uint16',
    'hr_type':'enum',
    'hr_zone_calc':'enum',
    'hrv_status':'enum',
    'hyperextension_exercise_name':'uint16',
    'intensity':'enum',
    'language':'enum',
    'language_bits_0':'uint8z',
    'language_bits_1':'uint8z',
    'language_bits_2':'uint8z',
    'language_bits_3':'uint8z',
    'language_bits_4':'uint8z',
    'lap_trigger':'enum',
    'lateral_raise_exercise_name':'uint16',
    'left_right_balance':'uint8',
    'left_right_balance_100':'uint16',
    'leg_curl_exercise_name':'uint16',
    'leg_raise_exercise_name':'uint16',
    'length_type':'enum',
    'local_date_time':'uint32',
    'local_device_type':'uint8',
    'localtime_into_day':'uint32',
    'lunge_exercise_name':'uint16',
    'manufacturer':'uint16',
    'max_met_category':'enum',
    'max_met_heart_rate_source':'enum',
    'max_met_speed_source':'enum',
    'mesg_count':'enum',
    'mesg_num':'uint16',
    'message_index':'uint16',
    'no_fly_time_mode':'enum',
    'olympic_lift_exercise_name':'uint16',
    'plank_exercise_name':'uint16',
    'plyo_exercise_name':'uint16',
    'power_phase_type':'enum',
    'pull_up_exercise_name':'uint16',
    'push_up_exercise_name':'uint16',
    'pwr_zone_calc':'enum',
    'radar_threat_level_type':'enum',
    'rider_position_type':'enum',
    'row_exercise_name':'uint16',
    'run_exercise_name':'uint16',
    'schedule':'enum',
    'segment_delete_status':'enum',
    'segment_lap_status':'enum',
    'segment_leaderboard_type':'enum',
    'segment_selection_type':'enum',
    'sensor_type':'enum',
    'session_trigger':'enum',
    'set_type':'uint8',
    'shoulder_press_exercise_name':'uint16',
    'shoulder_stability_exercise_name':'uint16',
    'shrug_exercise_name':'uint16',
    'side':'enum',
    'sit_up_exercise_name':'uint16',
    'sleep_level':'enum',
    'source_type':'enum',
    'split_type':'enum',
    'spo2_measurement_type':'enum',
    'sport':'enum',
    'sport_bits_0':'uint8z',
    'sport_bits_1':'uint8z',
    'sport_bits_2':'uint8z',
    'sport_bits_3':'uint8z',
    'sport_bits_4':'uint8z',
    'sport_bits_5':'uint8z',
    'sport_bits_6':'uint8z',
    'sport_event':'enum',
    'squat_exercise_name':'uint16',
    'stroke_type':'enum',
    'sub_sport':'enum',
    'supported_exd_screen_layouts':'uint32z',
    'swim_stroke':'enum',
    'switch':'enum',
    'tap_sensitivity':'enum',
    'time_into_day':'uint32',
    'time_mode':'enum',
    'time_zone':'enum',
    'timer_trigger':'enum',
    'tissue_model_type':'enum',
    'tone':'enum',
    'total_body_exercise_name':'uint16',
    'triceps_extension_exercise_name':'uint16',
    'turn_type':'enum',
    'user_local_id':'uint16',
    'warm_up_exercise_name':'uint16',
    'watchface_mode':'enum',
    'water_type':'enum',
    'weather_report':'enum',
    'weather_severe_type':'enum',
    'weather_severity':'enum',
    'weather_status':'enum',
    'weight':'uint16',
    'wkt_step_duration':'enum',
    'wkt_step_target':'enum',
    'workout_capabilities':'uint32z',
    'workout_equipment':'enum',
    'workout_hr':'uint32',
    'workout_power':'uint32'}




  • Thanks for the clarification.  In future I plan to create a custom profile from Profile.xlsx.

    By the way, I noted that the Type Sheet in Profile.xlsx uses the alignment to differentiate the values.

    Left alignment is for normal values (e.g. elements/members/enumerators of an type) and right alignment for special values (e.g. static variable).

    It this correct?

  • There is nothing significant about the formatting.