NetBurner 3.5.6
PDF Version
Overload Directory & System Files

Additional instructions if the overload directory is used in an NBEclipse project:

NetBurner Overload Directory Example

Overview

This example demonstrates how to use the NetBurner overload directory feature to override system files in a project-specific manner. The overload directory allows developers to modify system configuration files without affecting other projects or the original NNDK installation.

The Overload Directory Example is a basic demonstration of the overload directory in a project. The overload directory is used to override any system file by including local copies of system source files or headers. This allows the user to make changes to system files exclusively for a project. The overload directory provides an alternative to modifying the original system files, which would affect all projects.

To use this feature, the file to be overloaded should be placed in the overload directory under a directory structure that matches the file's location relative to the NNDK install directory.

This example application utilizes the overload directory to override predef.h (a NetBurner configuration header file). The overloaded predef.h defines the macro NBRTOS_TIME, which is not defined by default.

To overload the predef.h header, the directory structure is replicated inside the overload directory. For example, predef.h is located in the following directory in the NNDK install:

    `/nburn/nbrtos/include/predef.h`

Therefore, the directory structure is replicated inside the overload directory with the following structure:

    `<project root>/overload/nbrtos/include/predef.h`
Note
Upon adding a overload folder to the "Include paths" list or adding a new file to the specified overload folder, the user will need to clean and rebuild the NetBurner Library. This can be done by selecting "Clean NetBurner System Library" under the "Build Targets" pull-down in the project. From that point on, modifying predef.h (or any overloaded source/header) will automatically rebuild the necessary files in the NetBurner Library when the project builds.

Application Description

The Overload Directory Example is a simple NetBurner application that showcases the overload directory functionality by:

  • Initializing the network stack
  • Enabling system diagnostics
  • Waiting for an active network connection
  • Continuously prompting the user to press any key to display task runtime information
  • Using the ShowTaskTimes() function, which is only available when the NBRTOS_TIME macro is defined

Key Features

Overload Directory Functionality

The overload directory provides a mechanism to override any system file by including local copies of system source files or headers. This approach offers several advantages:

  • Project-specific modifications: Changes only affect the current project
  • Preserves original system files: No modification of the original NNDK installation
  • Maintainable: Easy to track and manage project-specific customizations

Example Implementation

This project demonstrates overloading the predef.h system header file to define the NBRTOS_TIME macro, which enables the ShowTaskTimes() function.

Directory Structure

The overload directory must replicate the directory structure of the file being overridden relative to the NNDK install directory.

Original System File Location

/nburn/nbrtos/include/predef.h

Overloaded File Location

<project root>/overload/nbrtos/include/predef.h

Files in This Example

main.cpp

The main application file that:

  • Initializes the NetBurner system
  • Waits for network connectivity
  • Provides an interactive loop for displaying task runtime information
  • Calls ShowTaskTimes() function (available due to overloaded predef.h)

predef-overload.h

Contains the overloaded configuration that defines:

#define NBRTOS_TIME (1)

This macro enables the compilation of task timing functionality in the NetBurner system library.

ReadMe.txt

The original documentation explaining the overload directory concept and usage instructions.

Setup Instructions for NBEclipse Projects

If using this example in an NBEclipse project, additional configuration is required:

  1. Right-click on the project in the "Project Explorer"
  2. Select "Properties"
  3. Navigate to C/C++ Build -> Settings
  4. Select GNU C++ Compiler -> Includes
  5. Add the overload include folder to the "Include paths" list
  6. For C code: Also add the overloaded folder to GNU C Compiler -> Includes
  7. Ensure the overload directory path is positioned above paths beginning with "$(NNDK_ROOT)/"
  8. Use up/down arrow buttons to reposition if necessary
  9. Select "Apply and close"

Building and Maintenance

Initial Setup

After adding an overload folder to the "Include paths" list or adding new files to the overload folder:

  1. Clean and rebuild the NetBurner Library
  2. Select "Clean NetBurner System Library" under the "Build Targets" pull-down

Ongoing Development

Once properly configured, modifying overloaded files (like predef.h) will automatically rebuild the necessary NetBurner Library files when the project builds.

Application Behavior

When running the application:

  1. The system initializes and waits for network connectivity
  2. Application name and NNDK revision information are displayed
  3. The program enters an interactive loop:
    • Prompts user to press any key
    • Displays current task runtime information using ShowTaskTimes()
    • Repeats indefinitely

Important Notes

  • The ShowTaskTimes() function is only available when NBRTOS_TIME is defined in predef.h
  • Improper include path configuration will result in "ShowTaskTimes was not declared" build errors
  • System diagnostics are enabled in this example and should be removed for production code
  • This example requires NetBurner hardware to execute