| View previous topic :: View next topic |
| Author |
Message |
skeezixcodejedi
Joined: 30 Aug 2005 Posts: 29
|
Posted: Tue Aug 30, 2005 11:19 am Post subject: sceIoOpen .. screwy? |
|
|
Edit: Please ignore the whole posting. Looks like a library problem, fiddling with library order solves it.. so must be sucking in some incorrect lib :(
--
After getting some weird results while mucking with some basic code using the defaults in PSPSDK I put together a dumb test case..
#if 1
int fd = 0;
UInt8 buffer [ 3 ] = { 0, 0, 0 };
UInt8 error = 0;
fd = sceIoOpen ( "ms0:/ATARI_ST/TOS.IMG", PSP_O_RDONLY, 0777 );
if ( fd ) {
if ( sceIoRead ( fd, buffer, 3 ) == 3 ) {
// good
} else {
error = 1;
}
sceIoClose ( fd );
}
#endif
And later, in the display loop..
pspDebugScreenSetXY ( 0, 0 );
pspDebugScreenPrintf ( "fd %d err %d bytes %x %x %x", fd, error,
buffer [ 0 ], buffer [ 1 ], buffer [ 2 ] );
So here I get a big -ve number for the fd; it should likely be 0 (failed) or 1 (good). Naturally, the subsequant calls also fail.
The file does exist, but thats irrelevent since I'm not getting a useful return value.
(Building under Windows for now, since PSP easily plugs into Windows :)
jeff _________________ --
Have you played Atari today?
Last edited by skeezixcodejedi on Tue Aug 30, 2005 11:36 am; edited 1 time in total |
|
| Back to top |
|
 |
skeezixcodejedi
Joined: 30 Aug 2005 Posts: 29
|
Posted: Tue Aug 30, 2005 11:23 am Post subject: |
|
|
Additionally, biulding sample/kernel/fileio sample compiles flawlessly, but crashes the PSP when run.
Thanks for any ideas!
jeff
edit: Actually the Makefile is missing USE_PSPSDK_LIBC=1 .. adding that and filio.c demo seems to work, so I'll go see if it wrote anything useful out (its a rom dumper). _________________ --
Have you played Atari today? |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Tue Aug 30, 2005 3:59 pm Post subject: |
|
|
| Quote: | | So here I get a big -ve number for the fd; it should likely be 0 (failed) or 1 (good). |
Actually, fd would be a file handle, so not necessarily 0 or 1. You'd have deliberately to try to open a non-existant file to find out what the error return code is.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
PSPimp
Joined: 12 Apr 2005 Posts: 13
|
Posted: Tue Aug 30, 2005 9:02 pm Post subject: Re: sceIoOpen .. screwy? |
|
|
| skeezixcodejedi wrote: | | So here I get a big -ve number for the fd; it should likely be 0 (failed) or 1 (good). Naturally, the subsequant calls also fail. |
assumption is the mother of all fuck-ups...
go and read up on open() return codes in your favourite "teach yourself C in 24 hours" book: <0 is failed, >=0 is a valid fd |
|
| Back to top |
|
 |
skeezixcodejedi
Joined: 30 Aug 2005 Posts: 29
|
Posted: Wed Aug 31, 2005 5:16 am Post subject: |
|
|
It really generally depends on the platform; most unix boxes return -1 on error and set errno; some platforms return 0. >0 or >=0 is usually success.
Getting -0xFFF0000 and such seems pretty weird :)
Still, nomatter.. just had to find it out. It helped when it wasn't returnign random values.. when using some mixture of libs, I got no useful returns back, and a different result each run. After futzing with libs, the problem went away so I've not documented it well I'm afraid :(
jeff _________________ --
Have you played Atari today? |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Wed Aug 31, 2005 5:22 am Post subject: |
|
|
Most PSP OS calls that create or open objects (such as sceIoOpen()) use a UID. UIDs are never negative, but they can be large numbers. You should never have to care about the details of any UID returned from the OS.
Just stick to < 0 == error, and >= 0 == success and you'll be fine. |
|
| Back to top |
|
 |
skeezixcodejedi
Joined: 30 Aug 2005 Posts: 29
|
Posted: Wed Aug 31, 2005 11:43 am Post subject: |
|
|
Words to live by :) It wasn't immediately obvious until I started getting those back :)
BTW, many kudos to yourself and the others who kicked the SDK off; incredible work. Easier to develop for than Palm OS and Pocket PC and even the GP32.. surprising!
jeff _________________ --
Have you played Atari today? |
|
| Back to top |
|
 |
|