Build Date Time for Version Control

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Build Date Time for Version Control

ソリューションへジャンプ
1,937件の閲覧回数
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,670件の閲覧回数
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,671件の閲覧回数
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,670件の閲覧回数
Teckna
Contributor V

Hi Yogendra,

Maybe the macro you are searching for is: __DATE__

Check the online help

Teckna