Build Date Time for Version Control

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Build Date Time for Version Control

跳至解决方案
1,906 次查看
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

标签 (1)
0 项奖励
回复
1 解答
1,639 次查看
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 项奖励
回复
2 回复数
1,640 次查看
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 项奖励
回复
1,639 次查看
Teckna
Contributor V

Hi Yogendra,

Maybe the macro you are searching for is: __DATE__

Check the online help

Teckna