To uniquely identify a code loaded on a controller, an individual build number can be used, which changes automatically with each successful compilation run. This build number can then be displayed as part of the version number, e.g. V1.01.0453. This tool creates a header file buildnumber.h with a build number or increments it if the file already exists. The tool should be called in the post-compile process. This ensures that each generated binary code receives an individual build number that can be queried and displayed
/* Generated by BuildNumber V2.1 */
#ifndef BUILD_NUMBER_H
#define BUILD_NUMBER_H
#define BUILDNUMBER BBB // Build number as Integer
#define BUILDNUMBER_STR "BBB" // Build number as String
#define VER_MAJOR MAJOR // Major version number as Integer
#define VER_MINOR MINOR // Minor version number as Integer
#define VERSION_STR "MAJOR.MINOR.BBB" // Version number as String
#define BUILDDATE_STR "YYYY-MM-DD hh:mm:ss" // Creation Date as String
#endif
The header file defines the build number as a number (BUILDNUMBER) and as a string (BUILDNUMBER_STR)
sprintf(&display[16], "V%.1u.%.2u.%.3u (MAIN)", VERSION_MAJOR, VERSION_MINOR, BUILDNUMBER); // Fill CANopen manufacturerSoftwareVersion object Ex: V1.01.1233
Increments the version and build number in a c-header file, or creates the c-header file if it does not exist.
Usage: Buildnumber [<path>] <file> [max]. Buildnumber (-h | -? | /h | /? )
Options: -h -? /h /? Display this screen.
path OPTIONAL Path in which to change or create the header. This is required e.g. when using the MPLABX macro $ {ProjectDir} (or $(ProjectDir) for VS/GCC) to determine the project directory.
file The name of the header file to be modified or created. The default filename is "buildnumber.h". Path can be included.
max OPTIONAL: Maximum build number. MINOR and MINOR are incremented if the build number is greater than max. If max = 0, MAJOR, MINOR and BUIL are reset to 0.0.000.
c:\microchip\buildnumber.exe ${ProjectDir} ".\buildnumber.h" 99 // Modifies or creates buildnumber.h in the MPLABX project directory with a maximum build number of 99. If greater, the MINOR version is incremented.
Error | No. |
---|---|
Maximum build number reached | -4 |
Error while parsing | -3 |
Could not create file | -1 |
Normal exit | 0 |