Build Date Time for Version Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Date Time for Version Control

Jump to solution
774 Views
yanam
Contributor II

Hi All

 

I am using CodeWarrior 10.4 for Kinetis. I would like to timestamp my builds with date-time at the build and use this string constant to print at the time of startup of the firmware. Does anyone have the idea of how it can be done in Eclipse/Codewarrior?

 

Regards,

Yogendra

Labels (1)
0 Kudos
1 Solution
507 Views
BlackNight
NXP Employee
NXP Employee

ANSI-C provides two macros:

__DATE__

__TIME__

which can be used for this. They get replaced by the compiler with the actual data and time.

I'm using this in my own firmware like this:

byte CLS1_PrintStatus(CLS1_ConstStdIOType *io)

{

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\nSYSTEM STATUS\r\n", io->stdOut);

  CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  CLS1_SendStatusStr((const unsigned char*)"Firmware", (const unsigned char*)__DATE__, io->stdOut);

  CLS1_SendStr((unsigned char*)" ", io->stdOut);

  CLS1_SendStr((unsigned char*)__TIME__, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  return ERR_OK;

}

You can see an example output of this in this blog post (last screenshot):

A Shell for the Freedom KL25Z Board

I hope this helps.

View solution in original post

0 Kudos
2 Replies
508 Views
BlackNight
NXP Employee
NXP Employee

ANSI-C provides two macros:

__DATE__

__TIME__

which can be used for this. They get replaced by the compiler with the actual data and time.

I'm using this in my own firmware like this:

byte CLS1_PrintStatus(CLS1_ConstStdIOType *io)

{

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\nSYSTEM STATUS\r\n", io->stdOut);

  CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  CLS1_SendStatusStr((const unsigned char*)"Firmware", (const unsigned char*)__DATE__, io->stdOut);

  CLS1_SendStr((unsigned char*)" ", io->stdOut);

  CLS1_SendStr((unsigned char*)__TIME__, io->stdOut);

  CLS1_SendStr((unsigned char*)"\r\n", io->stdOut);

  return ERR_OK;

}

You can see an example output of this in this blog post (last screenshot):

A Shell for the Freedom KL25Z Board

I hope this helps.

0 Kudos
507 Views
Teckna
Contributor V

Hi Yogendra,

Maybe the macro you are searching for is: __DATE__

Check the online help

Teckna