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 

Debug file not receiving characters

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



Joined: 26 Aug 2009
Posts: 13

PostPosted: Wed Sep 02, 2009 2:13 am    Post subject: Debug file not receiving characters Reply with quote

I'm building my app using kxploit and installing it on 3.52 M33 firmware to the PSP/GAME150 directory.

I use the following code to print to a debug file:
Code:

FILE * g_DbgFile;

void DBG_Init()
{
#ifdef DBG_TO_FILE
   g_DbgFile = fopen ("./simpleplatformdbg.txt","w");
   fprintf ( g_DbgFile, "Debug file opened" );
#endif
}


Once I run the app the txt file appears in the application directory but there is no text within it.

What am I doing wrong?
Back to top
View user's profile Send private message
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Wed Sep 02, 2009 3:15 am    Post subject: Reply with quote

I've tried adding a fflush incase that was the problem but still no joy.

One thought I've had is to use the SceIo API instead. This raises a couple of questions in my mind.

(i) Should I expect fprintf to work on the PSP?

(ii) This is an SDL app. Will this interfere with the SceIo API?
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Sep 02, 2009 7:01 am    Post subject: Reply with quote

Did you close the file?
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Wed Sep 02, 2009 7:34 am    Post subject: Reply with quote

Yes, closing the file writes everything to it.

But this isn't a very good solution since I'm trying to debug a problem that crashes the PSP necessitating a power up.

Surely I don't have to close and reopen the file each time I want to log to it.

Or is there a way of trapping the crash so that I can close the file appropriately?
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Sep 02, 2009 9:34 am    Post subject: Reply with quote

>Surely I don't have to close and reopen the file each time I want to log to it.
What's wrong with that?
You could use psplink and print to stderr to see your debug info

>Or is there a way of trapping the crash so that I can close the file appropriately?
Install an exception handler
Link
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Sep 02, 2009 4:28 pm    Post subject: Reply with quote

You really shouldn't be doing anything with the 1.50 kernel anymore. There is simply NO need for it for almost any homebrew application.
Back to top
View user's profile Send private message
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Fri Sep 04, 2009 12:59 am    Post subject: Reply with quote

Torch wrote:
You really shouldn't be doing anything with the 1.50 kernel anymore. There is simply NO need for it for almost any homebrew application.


Thanks for the tip. The deal is I've picked up a project from a couple of years ago so my setup is outdated.

If someone could link me to a thread summarising the most current stable environment (toolchain, firmware, etc.) it would be most appreciated.
Back to top
View user's profile Send private message
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Fri Sep 04, 2009 1:32 am    Post subject: Reply with quote

psPea wrote:
>Surely I don't have to close and reopen the file each time I want to log to it.
What's wrong with that?


Isn't that innefficient?
Back to top
View user's profile Send private message
ab5000



Joined: 06 May 2008
Posts: 74

PostPosted: Fri Sep 04, 2009 1:40 am    Post subject: Reply with quote

platform wrote:
psPea wrote:
>Surely I don't have to close and reopen the file each time I want to log to it.
What's wrong with that?


Isn't that innefficient?


i read it's not possible to do a fflush on psp. You can do a devctl to memorystick to fulsh ALL the files. opening, writing and closing is more efficient ;)
_________________
Code:
%:include<stdio.h>
int _(int __,int ___,int ____,int _____)
<%for(;____<___;_____=_____*__,____++);
return _____;%>main()<%printf
("%d\n",_(2,5,0,1));%>
Back to top
View user's profile Send private message
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Fri Sep 04, 2009 2:13 am    Post subject: Reply with quote

ab5000 wrote:
platform wrote:
psPea wrote:
>Surely I don't have to close and reopen the file each time I want to log to it.
What's wrong with that?


Isn't that innefficient?


i read it's not possible to do a fflush on psp. You can do a devctl to memorystick to fulsh ALL the files. opening, writing and closing is more efficient ;)


ab - thanks for the tip, looks like I'll get my head around installing the exception handler.

pea - when I try the open, write, close regime I find two problems
On the development machine I keep getting a crash on the fprintf after 10 secs or so.
Execution on the PSP is horribly slow and eventually I get the crash.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri Sep 04, 2009 2:23 am    Post subject: Reply with quote

As pointed out if you get psplink running it comes with its own exception handler so you dont need to set up anything else and will help in development and debugging to boot.
Back to top
View user's profile Send private message
ab5000



Joined: 06 May 2008
Posts: 74

PostPosted: Fri Sep 04, 2009 5:27 am    Post subject: Reply with quote

BTW, this is from pspsdk/src/libc/stdio.c:

Code:
int fflush(FILE *stream)
{
  int ret = EOF; // Same as default case below.

  switch(LOCAL_FILE(stream)->type) {
    case STD_IOBUF_TYPE_GE:
    case STD_IOBUF_TYPE_STDOUTHOST:
      /* stdout & stderr are never buffered. */
    case STD_IOBUF_TYPE_UMD:
      /* cd-rom files are read-only so no write buffer to flush. */
      ret = 0;
      break;
    case STD_IOBUF_TYPE_MS:
      if (LOCAL_FILE(stream)->flag & (_IOWRT | _IORW)) {
        //if (ret != 0) ret = EOF;
        /* Need to implement sync or something */
      }
      else ret = 0;
      break;
    case STD_IOBUF_TYPE_HOST:
      /* flush host file write buffer. */
      if (LOCAL_FILE(stream)->flag & (_IOWRT | _IORW)) ret = 0;
      else ret = 0;
      break;
    default:
      /* unknown/invalid I/O buffer type. */
      ret = EOF;
  }
  return (ret);
}


as you can see, flushing isn't implemented for MS ;)
_________________
Code:
%:include<stdio.h>
int _(int __,int ___,int ____,int _____)
<%for(;____<___;_____=_____*__,____++);
return _____;%>main()<%printf
("%d\n",_(2,5,0,1));%>
Back to top
View user's profile Send private message
platform



Joined: 26 Aug 2009
Posts: 13

PostPosted: Fri Sep 04, 2009 6:03 am    Post subject: Reply with quote

TyRaNiD wrote:
As pointed out if you get psplink running it comes with its own exception handler so you dont need to set up anything else and will help in development and debugging to boot.


OK, so I'm now trying to install the most recent toolchain but I can't find libusb-dev for OSX anywhere. Does anyone know where this is?
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Fri Sep 04, 2009 9:34 pm    Post subject: Reply with quote

Why don't you just do this:

- Open as append
- Write data
- Close

That's how i do it, and in combination with psplink it works like a charm ;)
_________________
The Incredible Bill Gates wrote:
The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
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