Search code examples
caplcanoe

How do I get the current Time in CAPL?


I am writing testresults I get into an .csv now I want to get a new .csv when I repeat the test.

my idea was to set the Timestamp at the End of the name of my .csv to tell them appart but I cant figure out how to do that.

my code is as follows:

setFilePath("C:XXXX", 2);
logFile = openFileWrite("Results.csv", 2);

if (tf1succes == 1) 
{
  snprintf(results, 1024, "TF01 was succesfull. \n");
  filePutString(results, 1024, logFile);       
}
else
{
  snprintf(results, 1024, "TF01 was not succesfull. \n");
  filePutString(results, 1024, logFile);       
}

fileClose(logFile);

getTime() - didnt work

getSystemTime() - didnt work


Solution

  • Extensive research in CANoe's documentation will lead to:

    getLocalTime which will get you an array of integers denoting seconds, minutes, hours, days, months, and so on.

    Or even

    getLocalTimeString which will get you a formatted datetime string.