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
Solved! Go to Solution.
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.
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.
Hi Yogendra,
Maybe the macro you are searching for is: __DATE__
Check the online help
Teckna