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 

sceIoOpen .. screwy?

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



Joined: 30 Aug 2005
Posts: 29

PostPosted: Tue Aug 30, 2005 11:19 am    Post subject: sceIoOpen .. screwy? Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
skeezixcodejedi



Joined: 30 Aug 2005
Posts: 29

PostPosted: Tue Aug 30, 2005 11:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Tue Aug 30, 2005 3:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PSPimp



Joined: 12 Apr 2005
Posts: 13

PostPosted: Tue Aug 30, 2005 9:02 pm    Post subject: Re: sceIoOpen .. screwy? Reply with quote

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
View user's profile Send private message
skeezixcodejedi



Joined: 30 Aug 2005
Posts: 29

PostPosted: Wed Aug 31, 2005 5:16 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Aug 31, 2005 5:22 am    Post subject: Reply with quote

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
View user's profile Send private message
skeezixcodejedi



Joined: 30 Aug 2005
Posts: 29

PostPosted: Wed Aug 31, 2005 11:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
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