class Crubyflie::ParamTOCElement

An element in the Parameters Table of Contents

Constants

C_RUBY_TYPE_MAP

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

Public Class Methods

new(data) click to toggle source

Initializes a Param TOC element, which means interpreting the data in the packet and calling the parent class @param data [String] a binary payload @todo It turns out this is the same as Log. Only the type conversion changes

Calls superclass method
# File lib/crubyflie/crazyflie/param.rb, line 88
def initialize(data)
    # The group and name are zero-terminated strings from the 3rd byte
    group, name = data[2..-1].unpack('Z*Z*')
    ident = data[0].ord()
    ctype_id = data[1].ord() & 0b1111  #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 # 5th bit

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