class Crubyflie::LogTOCElement

An element in the Logging Table of Contents A LogTOCElement knows what the type of data that comes in a LogBlock and is able to initialize the TOCElement from a TOC Logging packet

Constants

C_RUBY_TYPE_MAP

A map between crazyflie C types and ruby directives to interpret them. This will help parsing the logging data

Public Class Methods

new(data) click to toggle source

Initializes a Log TOC element, which means interpreting the data in the packet and calling the parent class @param data [String] a binary payload

Calls superclass method
# File lib/crubyflie/crazyflie/log.rb, line 77
def initialize(data)
    # unpack two null padded strings
    group, name = data[2..-1].unpack('Z*Z*')
    ident = data[0].ord()
    ctype_id = data[1].ord() & 0b1111 # go from 0 to 15
    ctype = C_RUBY_TYPE_MAP[ctype_id][:ctype]
    directive = C_RUBY_TYPE_MAP[ctype_id][:directive]
    access = data[1].ord & 0b00010000 # 0x10, the 5th bit

    super({
              :ident => ident,
              :group => group,
              :name  => name,
              :ctype => ctype,
              :type_id => ctype_id,
              :directive => directive,
              :access => access
          })
end