| View previous topic :: View next topic |
| Author |
Message |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Wed Sep 02, 2009 2:13 am Post subject: Debug file not receiving characters |
|
|
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 |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Wed Sep 02, 2009 3:15 am Post subject: |
|
|
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 |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Wed Sep 02, 2009 7:01 am Post subject: |
|
|
Did you close the file? _________________ Click ME! |
|
| Back to top |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Wed Sep 02, 2009 7:34 am Post subject: |
|
|
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 |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Wed Sep 02, 2009 9:34 am Post subject: |
|
|
>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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Sep 02, 2009 4:28 pm Post subject: |
|
|
| 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 |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Fri Sep 04, 2009 12:59 am Post subject: |
|
|
| 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 |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Fri Sep 04, 2009 1:32 am Post subject: |
|
|
| 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 |
|
 |
ab5000
Joined: 06 May 2008 Posts: 74
|
Posted: Fri Sep 04, 2009 1:40 am Post subject: |
|
|
| 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 |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Fri Sep 04, 2009 2:13 am Post subject: |
|
|
| 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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Fri Sep 04, 2009 2:23 am Post subject: |
|
|
| 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 |
|
 |
ab5000
Joined: 06 May 2008 Posts: 74
|
Posted: Fri Sep 04, 2009 5:27 am Post subject: |
|
|
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 |
|
 |
platform
Joined: 26 Aug 2009 Posts: 13
|
Posted: Fri Sep 04, 2009 6:03 am Post subject: |
|
|
| 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 |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Fri Sep 04, 2009 9:34 pm Post subject: |
|
|
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 |
|
 |
|