forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help outputting the system clock

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
funkmeister



Joined: 10 May 2006
Posts: 8

PostPosted: Wed May 10, 2006 10:36 am    Post subject: Help outputting the system clock Reply with quote

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:
    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.
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Wed May 10, 2006 10:52 am    Post subject: Reply with quote

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

edit2:
Code:
pspTime time;
    sceRtcGetCurrentClockLocalTime(&time);
or something like it.. looks like pointers are being messed up.
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Wed May 10, 2006 12:49 pm    Post subject: Reply with quote

%u16 will print an unsigned number followed by a 16.... heh
Back to top
View user's profile Send private message AIM Address MSN Messenger
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Wed May 10, 2006 2:53 pm    Post subject: Reply with quote

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:

    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
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Wed May 10, 2006 3:28 pm    Post subject: Reply with quote

heh, we're all confusing ourselves over this one :)
Code:
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!
Back to top
View user's profile Send private message
funkmeister



Joined: 10 May 2006
Posts: 8

PostPosted: Wed May 10, 2006 10:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Wed May 10, 2006 10:59 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
funkmeister



Joined: 10 May 2006
Posts: 8

PostPosted: Thu May 11, 2006 2:17 am    Post subject: Reply with quote

Again, thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group