Tasking

Hej

Can anyone easily explain how i in tasking compiler redirect printf to the seriel channel by replacing putchar ???

Kasper

Reply to
Kasper
Loading thread data ...

On 09/03/2006 the venerable Kasper etched in runes:

seriel channel by

'putchar()' is a library function. If you write your own function in your source code then the linker should use it in preference to the library function.

--
John B
Reply to
John B

Hej

Also what i have done in ICC working very well, i think i have to try again :)

Kasper

Reply to
Kasper

In some systems putchar is a macro. So it may already be expanded in printf, in which case redefining it will have no effect. Take a look at the definitions of putchar and printf.

However, when putchar fills a buffer it typically calls something like fflush() or write(). You may be able to redefine these.

--
	mac the naïf
Reply to
Alex Colvin

Hey

i think you are right with macro.... can you wxplain a litle more when i add some from the stdio.h ?

Here we go: extern int getc ( FILE * ); extern int getchar ( void ); extern int fgetc ( FILE * ); extern char * fgets ( char * restrict, int, FILE * restrict ); extern int putc ( int, FILE * ); extern int putchar ( int ); extern int fputc ( int, FILE * ); extern int fputs ( const char * restrict, FILE * restrict ); extern char * gets ( char * ); extern int puts ( const char * ); extern void clearerr ( FILE * ); extern int feof ( FILE * ); extern int ferror ( FILE * ); extern void perror ( const char * ); extern int ungetc ( int, FILE * );

/* Direct input/output */ extern size_t fread ( void * restrict, size_t, size_t, FILE * restrict ); extern size_t fwrite ( const void * restrict, size_t, size_t, FILE * restrict ); extern FILE * fopen ( const char * restrict, const char * restrict ); extern FILE * freopen ( const char * restrict, const char * restrict, FILE

  • restrict ); extern int fclose ( FILE * ); extern int fflush ( FILE * ); extern int setvbuf ( FILE * restrict, char * restrict, int, size_t ); extern void setbuf ( FILE * restrict, char * restrict ); extern int fgetpos ( FILE * restrict , fpos_t * restrict ); extern int fseek ( FILE * , long , int ); extern int fsetpos ( FILE * , const fpos_t * ); extern long ftell ( FILE * ); extern int remove ( const char * ); extern int rename ( const char *, const char * ); extern void rewind ( FILE * ); extern FILE * tmpfile ( void ); extern char * tmpnam ( char * );

/* Prototypes we need for getc()/putc() */ extern int _filbuf ( FILE * ); extern int _flsbuf ( int, FILE * );

#define getc(p) (++(p)->_cnt_ptr++): _filbuf(p)) #define getchar() getc(stdin) #define putc(x,p) (--(p)->_cnt>=0 ? \ (unsigned char)(*(p)->_ptr++=((char)(x))): \ _flsbuf((unsigned char)(x),p)) #define putchar(x) putc(x,stdout) #define feof(p) (((p)->_flag&_IOEOF)!=0) #define ferror(p) (((p)->_flag&_IOERR)!=0) #define fileno(p) p->_file #define clearerr(p) ((void)(p->_flag &= ~(_IOEOF|_IOERR)))

#ifdef __cplusplus } #endif /* defined(__cplusplus) */

#endif /* _STDIO_H */

Reply to
Kasper

Hey

Seems to work if i use fputc and make a new of that one, i just don't understan why it has to be Fputc ??

Kasper

Reply to
Kasper

perhaps putchar(C) is a macro for putc(C,stdout), which is defined as a macro for fputc(C,S)

on BSD, fputc is documented as a function but putc is a macro.

--
	mac the naïf
Reply to
Alex Colvin

Myabe the F for funtion and not file ?

Kasper

Reply to
Kasper

I would attribute it to evolution, rather than intelligent design.

--
	mac the naïf
Reply to
Alex Colvin

You may have been looking in the mapfile and are looking at the mangled name. The compiler will prepend 'F' to function names. This avoids naming conflicts in mixed C/asm projects where you might inadvertently use the same name on C and assembly level. Also have a look on:

formatting link

And pick ex039009 or ex039011. Or enrole into the TASKING/ Altium forum:

formatting link

Regards,

--
Henk-Piet Glas                             Support Engineer
-----------------------------------------------------------
 Click to see the full signature
Reply to
Henk-Piet Glas

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.