Help outputting the system clock

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
funkmeister
Posts: 8
Joined: Wed May 10, 2006 10:25 am

Help outputting the system clock

Post by funkmeister »

I'm having trouble getting the methods in psprtc.h to cooperate. Could anybody give me an example of how to retreive the values of the system clock, and cast them from U16s to INTs?

The code i'm trying now is

Code: Select all

    pspTime *time;
    sceRtcGetCurrentClockLocalTime(*time);
    printf("The current time is:");
    printf("\nhours: %u16",time->hour);
    printf("\nminutes: %u16",time->minutes);
    printf("\nseconds: %u16",time->seconds);
It works....but the output is some rediculous value...and it's consistiently the SAME value, no matter when I run it.

Thanks in advance for any help.
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

edit: forget me, just looked up my reference.. %u should be fine, but drop the 16 just after it.

edit2:

Code: Select all

pspTime time;
    sceRtcGetCurrentClockLocalTime(&time);
or something like it.. looks like pointers are being messed up.
Damn, I need a decent signature!
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

%u16 will print an unsigned number followed by a 16.... heh
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

You messing up with the pointers. You haven't allocated any memory for the time structure, you only have an uninitialized pointer. Modifying your code as below should do the trick.

Code: Select all

    pspTime time;
    sceRtcGetCurrentClockLocalTime(&time);
    printf("The current time is:");
    printf("\nhours: %d",time->hour);
    printf("\nminutes: %d",time->minutes);
    printf("\nseconds: %d",time->seconds);
Br, Sandberg
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

heh, we're all confusing ourselves over this one :)

Code: Select all

pspTime time;
    sceRtcGetCurrentClockLocalTime(&time);
    printf("The current time is:");
    printf("\nhours: %d",time.hour);
    printf("\nminutes: %d",time.minutes);
    printf("\nseconds: %d",time.seconds);
(ie no longer arrow operator on the struct)
Damn, I need a decent signature!
funkmeister
Posts: 8
Joined: Wed May 10, 2006 10:25 am

Post by funkmeister »

Thanks a bunch! I'll try recompiling it when I get home after work.

For the records, the arrow format was suggested to me by a friend of mine who's a software engineer with 5 years experience. Just goes to show you that you can never know everything. :P
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

funkmeister wrote:Thanks a bunch! I'll try recompiling it when I get home after work.

For the records, the arrow format was suggested to me by a friend of mine who's a software engineer with 5 years experience. Just goes to show you that you can never know everything. :P
The arrows was correct in your original post, where time was a pointer. I my changed suggestion, you need to use the . as cheriff corrected me. I forgot to change that.
Br, Sandberg
funkmeister
Posts: 8
Joined: Wed May 10, 2006 10:25 am

Post by funkmeister »

Again, thank you.
Post Reply