| View previous topic :: View next topic |
| Author |
Message |
funkmeister
Joined: 10 May 2006 Posts: 8
|
Posted: Wed May 10, 2006 10:36 am Post subject: Help outputting the system clock |
|
|
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 |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Wed May 10, 2006 10:52 am Post subject: |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Wed May 10, 2006 12:49 pm Post subject: |
|
|
| %u16 will print an unsigned number followed by a 16.... heh |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Wed May 10, 2006 2:53 pm Post subject: |
|
|
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 |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Wed May 10, 2006 3:28 pm Post subject: |
|
|
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 |
|
 |
funkmeister
Joined: 10 May 2006 Posts: 8
|
Posted: Wed May 10, 2006 10:16 pm Post subject: |
|
|
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 |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Wed May 10, 2006 10:59 pm Post subject: |
|
|
| 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 |
|
 |
funkmeister
Joined: 10 May 2006 Posts: 8
|
Posted: Thu May 11, 2006 2:17 am Post subject: |
|
|
| Again, thank you. |
|
| Back to top |
|
 |
|