Log Entry

The log defines a number of entry types to collect information. The definition of the various entry types can be found in the user guide.

Log Entry Class

class WlanExpLogEntryType(name=None, entry_type_id=None)[source]

Class to define a log entry type.

get_field_names()[source]

Get the field names of the log entry.

Returns:names – List of string field names for the entry
Return type:list of str
get_field_struct_formats()[source]

Get the Python struct format of the log entry fields.

Returns:formats – List of Python struct formats for the fields in the log entry
Return type:list of str
get_entry_type_id()[source]

Get the ID for the entry type.

Returns:ID – Integer ID for the log entry
Return type:int
append_field_defs(field_info)[source]

Adds fields to the definition of the log entry type.

Parameters:

field_info (list of tuple) – Each must be of the form (field_name, field_type_struct, field_type_numpy) where:

  • field_name: Name of field as string
  • field_type_struct: Field type as string, using formats specified by struct module
  • field_type_numpy: Field type as string, using formats specified by numpy dtype
  • field_desc: String describing the field’s meaning, used to generate wiki docs
modify_field_def(name, struct_type, numpy_type, doc_str=None)[source]

Modifies fields of the definition of the log entry type.

Parameters:
  • name (str) – Name of field to modify
  • struct_type (str) – New Python struct type for the field
  • numpy_type (str) – New numpy type for the field
  • doc_str (str, optional) – New documentation string
add_gen_numpy_array_callback(callback)[source]

Add callback that is run after the numpy array is generated from the entry type.

The callbacks will be executed in the order the are added to the log entry

Parameters:callback (function) – Function to run after the numpy array is generated
deserialize(buf)[source]

Unpacks one or more raw log entries of the same type into a list of dictionaries

Parameters:buf (bytearray) – Array of raw log data containing 1 or more log entries of the same type.
Returns:entries – Each dictionary in the list has one value per field in the log entry definition using the field names as keys.
Return type:List of dict
serialize(entries)[source]

Packs one or more list of dictionaries into a buffer of log entries of the same type

Parameters:entry_list (dictionary) – Array of dictionaries for 1 or more log entries of the same type
Returns:data – Bytearray of packed binary data
Return type:bytearray

Log Entry Functions

np_array_add_fields(np_arr_orig, mac_addr=False, ltg=False, docs_only=False)[source]

Add ‘virtual’ fields to the numpy array.

This is an example of a gen_numpy_array_callback

Parameters:
  • np_arr_orig (Numpy Array) – Numpy array to extend
  • mac_addr (bool, optional) – Add MAC address information to the numpy array?
  • ltg (bool, optional) – Add LTG information ot the numpy array?
  • docs_only (bool) – Only generate documentation strings for virtual fields? If this is True, then only documentation strings are returned.
Returns:

np_array – Updated numpy array

Return type:

Numpy Array

Extend the default np_arr with convenience fields for:
  • MAC header addresses
  • LTG packet information

IMPORTANT: np_arr uses the original bytearray as its underlying data We must operate on a copy to avoid clobbering log entries adjacent to the Tx or Rx entries being extended.