Hej
Can anyone easily explain how i in tasking compiler redirect printf to the seriel channel by replacing putchar ???
Kasper
Hej
Can anyone easily explain how i in tasking compiler redirect printf to the seriel channel by replacing putchar ???
Kasper
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
Hej
Also what i have done in ICC working very well, i think i have to try again :)
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
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
/* 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 */
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
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
Myabe the F for funtion and not file ?
Kasper
I would attribute it to evolution, rather than intelligent design.
-- mac the naïf
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:
And pick ex039009 or ex039011. Or enrole into the TASKING/ Altium forum:
Regards,
-- Henk-Piet Glas Support Engineer -----------------------------------------------------------
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.