Menu

AFP resource consumption on micro-controllers

Reducing resource consumption

Famouso and AFP provide several possibilities to reduce the resource consumption which is important for resource constrained embedded systems like micro-controllers.

Many proposals assume that you know how to configure AFP. See How to configure AFP and Changing AFP configuration used in the Abstract Network Layer on this topic.

  1. Choose the most simple sufficient configuration! Supporting less features results in less code and less RAM usage.
  2. If you do not need to support events longer than 255 bytes, you can instruct AFP to use smaller data types with the following AFP config line:
     typedef afp::MinimalSizeProp SizeProperties; 
    
  3. Adjust the values of the config options:
  4. Define a custom Allocator policy. You can reduce the size of the memory pool to save RAM or a different special allocator. E.g. if multiple_subjects = event_seq = duplicates = reordering = FEC = false you can use object::OneBlockAllocator.
  5. You may disable overflow_error_checking.

Reducing resource consumption in general for release versions:

  1. Define the preprocessor symbol LOGGING_DISABLE when invoking the compiler to disable logging globally.
  2. Define the preprocessor symbol NDEBUG to disable all run-time assertions.

Resource consumption examples

The following table illustrates the Flash and RAM resource consumption of some simple AFP configurations on an AVR at90can128 micro-controller build with avr-g++ 4.4.3. The values include the famouso middleware and a CAN driver. The source is located in the directory tst/approved/AFP/avr-size.

Node type

Max. event size (Bytes)

AFP

Section text (Bytes)

Section data (Bytes)

Section bss (Bytes)

Filename

publisher

8

none

2594

28

38

can-pub-no-afp

255

ANL

3604

28

38

can-pub-anl

255

Application Layer

3060

28

38

can-pub-al

subscriber

8

none

2640

28

38

can-sub-no-afp

255

ANL

4092

28

347

can-sub-anl

255

Application Layer

3386

28

301

can-sub-al