printf() doesn't print anything to the terminal.

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has thanked: 0
Been thanked: 0
Contact:

printf() doesn't print anything to the terminal.

Post by JS Lemming »

I recently got a Dreamcast Development setup on my linux system and found that printf() does nothing for me (doesn't print stuff to the terminal). It used to work when I had it set up for windows using the DC Dev ISO. I have a faint memory of someone saying that communication bewteen the terminal can be switched on or off depending on if the program you're working on is about to be released (off is faster or something) but can't remember. Anyone know how I can get that working again?

BTW, if it matters, I'm using dc-tool 1.0.3 by <andrewk@napalm-x.com>... I've heard of a version 4 or might have even had the source to it at one point but I was unable to compile it. But I'm assuming 1.0.3 can handle things just fine.

PS: I use coder's cable.
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by dospro »

I have described that problem in my post with no solution yet.
There i trierd dc-tool-ip(BBA) 1.0.3 and 1.0.4.
The printfs just don't work.
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5660
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

There is an odd problem with printf()s in KOS that I have yet to find....

As a temporary measure, you could always use dbglog instead:

Code: Select all

dbglog(DBG_DEBUG, "Insert message here\n");
dbglog can be used just like printf, with the addition of the first parameter. I, so far, haven't seen any problems with using dbglog for printing, plus, you can change the level of the stuff being printed, so that in a finalized release, you just set that you don't want anything with a level of less than a certain amount to be printed, and it won't be. Here's the relevant values for the first parameter to that function, by the way.

Code: Select all

#define DBG_DEAD	0		/* The system is dead */
#define DBG_CRITICAL	1		/* A critical error message */
#define DBG_ERROR	2		/* A normal error message */
#define DBG_WARNING	3		/* Potential problem */
#define DBG_NOTICE	4		/* Normal but significant */
#define DBG_INFO	5		/* Informational messages */
#define DBG_DEBUG	6		/* User debug messages */
#define DBG_KDEBUG	7		/* Kernel debug messages */
The higher the number, the lower priority the message is. (Most things inside KOS use the DBG_KDEBUG level).

I hope this helps out...

By the way, this is all in the <kos/dbglog.h> header, so if you're not including <kos.h>, make sure to include that or you'll have compilation errors...
Phantom
DC Developer
DC Developer
Posts: 1753
Joined: Thu Jan 16, 2003 4:01 am
Location: The Netherlands
Has thanked: 0
Been thanked: 0
Contact:

Post by Phantom »

I've had some issues with standard file descriptors on GP32 as well. I fixed it there by calling newlib's init routine manually: __sinit(_impure_ptr);

There's probably no relation to the DC issue though, but I thought I'd mention it just in case.
"Nothing works" - Catweazle
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has thanked: 0
Been thanked: 0
Contact:

Post by JS Lemming »

Thanks BlueCrab, even though I don't think I can print variables with that function which is what I really need to do. BTW, I just found out that using printf without passing a variable works... like:

Code: Select all

printf("This works!\n");

printf("But this doesn't work! %f",corn);
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5660
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

You can print variables with the function.
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has thanked: 0
Been thanked: 0
Contact:

Post by JS Lemming »

Wha? Can you show me a code example of printing variables with that? Cause I tried and the compilor spewed errors. Float if you don't mind.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5660
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

It should just work exactly like printf(), with the exception of the additional first argument.... Here's a bit of code from kos/kernel/net/net_udp.c:

Code: Select all

    if(checksum != ps->checksum) {
        dbglog(DBG_KDEBUG, "net_udp: discarding UDP packet with invalid "
                           "checksum\n"
                           "         calculated 0x%04X, sent 0x%04X\n",
               ps->checksum, checksum);
        return -1;
    }
It should handle float variables just the same as printf(). If you don't mind, paste the errors you get out of gcc when trying to compile and the relevant code that's causing the errors, of course.
User avatar
semicolo
Mental DCEmu
Mental DCEmu
Posts: 328
Joined: Mon Apr 25, 2005 1:02 pm
Location: Three-rivers canada
Has thanked: 0
Been thanked: 0
Contact:

Post by semicolo »

I've another problem with printf on a coder's cable, the first letter is missing (easy fixed by adding spaces befor the strings...) this thing appeared about a year ago, probably after a toolchain or kos upgrade.
Post Reply