ctime gives worn return date - VxWorks

This is a discussion on ctime gives worn return date - VxWorks ; Hi, I am using a GPS device to give me the number of seconds since Jan 1, 1970. The value may be something like 1189685068, which corresponds to Sept 13, sometime around 8:00am EST. The returned string from ctime is ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: ctime gives worn return date

  1. ctime gives worn return date

    Hi,

    I am using a GPS device to give me the number of seconds since Jan 1,
    1970. The value may be something like 1189685068, which corresponds to
    Sept 13, sometime around 8:00am EST. The returned string from ctime is
    "THU DEC 56 12:04:28 2007". It appears to have the right day (THU) and
    time (12:04 UTC or 8:04 EST) but the wrong date (DEC 56). Has anybody
    seen behavior like this before?

    Some more details: When I start the board and get the time, the string
    returned from ctime is correct (eg THU SEP 13 08:46:34 2007), but
    after a few hours the date suddenly changes to an invalid date, but
    everything else seems to be correct.

    This is running on a PowerPC 603e, using VxWorks 5.3.1 (yes, it is a
    very old system). I am adding some code to try to track down a problem
    and I am logging events. I use the GPS time to keep track of when
    things occur. Here is a snippet of some of the code I use to log
    stuff (theTimeData is a char* with an allocated size of 100):

    unsigned int gpsTime = 0;
    // zero out the time string for next time
    bzero(theTimeData, SIZE_OF_TIME_DATA);

    while (true)
    {
    .... // open file here

    // get the time data from the AHRS
    if (OK == getGPSTime(&gpsTime))
    {
    // convert to readable format to place in the log
    theTimeData = ctime((time_t*)&gpsTime);

    // write the string to the file
    totalBytesWritten = fdprintf(theLogFile, theTimeData);
    if(ERROR == totalBytesWritten)
    {
    ...

    // zero out the time string for next time
    bzero(theTimeData, SIZE_OF_TIME_DATA);

    ...
    }
    else
    {
    // zero out the time string for next time
    bzero(theTimeData, SIZE_OF_TIME_DATA);

    gpsTime = 0;
    }
    ....
    }

    Any help is greatly appreciated. I have printed out the seconds that
    are returned from the GPS and they are valid and correct according to
    time.gov.


  2. Re: ctime gives worn return date

    Wow, should have spell checked the title. Sorry about that. It should
    be "Wrong" not "worn" don't know how that happened.


  3. Re: ctime gives worn return date

    Figured it out. Once I use the reentrant version, everything comes out
    fine.


+ Reply to Thread