How to use the choochoo.fit.decode.Identity function in choochoo

To help you get started, we’ve selected a few choochoo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andrewcooke / choochoo / choochoo / fit / decode.py View on Github external
def header_defn(log, types, messages):
    message = messages.number_to_message(HEADER_GLOBAL_TYPE)
    return Definition(log, Identity(message.name, Counter()), LITTLE, message,
                      [Field(log, field[1] * types.profile_to_type(field[2]).size,
                             message.number_to_field(n),
                             types.profile_to_type(field[2]))
                       for n, field in enumerate(HEADER_FIELDS)],
                      (),
                      {'header_size'})  # this needed as reference for optional field logic
github andrewcooke / choochoo / choochoo / fit / decode.py View on Github external
def __add_definition(self, local_type, extended):
        endian = self.__data[self.__offset+2] & 0x1
        global_type = unpack('<>'[endian]+'H', self.__data[self.__offset+3:self.__offset+5])[0]
        message = self.__messages.number_to_message(global_type)
        identity = Identity(message.name, self.__defn_counter)
        n_fields = self.__data[self.__offset+5]
        fields = tuple(self.__fields(self.__field,self.__offset+6, n_fields, message))
        offset = 6 + n_fields * 3
        if extended:
            n_dev_fields = self.__data[self.__offset+offset]
            dev_fields = tuple(self.__fields(self.__dev_field, self.__offset+offset+1, n_dev_fields))
            offset += 1 + n_dev_fields * 3
        else:
            dev_fields = ()
        self.__definitions[local_type] = Definition(self.__log, identity, endian, message, fields, dev_fields)
        return offset