Motherboard Forums


Reply
 
 





















Kasper
Guest
Posts: n/a

 
      03-09-2006, 05:30 PM


Hej

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


Kasper


 
Reply With Quote
 
John B
Guest
Posts: n/a

 
      03-09-2006, 05:45 PM
On 09/03/2006 the venerable Kasper etched in runes:

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


'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 With Quote
 
Kasper
Guest
Posts: n/a

 
      03-09-2006, 05:53 PM

"John B" <> wrote in message
news:441069d3$0$818$ t...
> On 09/03/2006 the venerable Kasper etched in runes:
>
>> Hej
>>
>> Can anyone easily explain how i in tasking compiler redirect printf to
>> the seriel channel by
>> replacing putchar ???
>>
>>
>> Kasper

>
> '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.


Hej

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


Kasper


 
Reply With Quote
 
Alex Colvin
Guest
Posts: n/a

 
      03-09-2006, 06:34 PM
>>> Can anyone easily explain how i in tasking compiler redirect printf to
>>> the seriel channel by
>>> replacing putchar ???

>>
>> '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.


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 With Quote
 
Kasper
Guest
Posts: n/a

 
      03-09-2006, 07:20 PM

"Alex Colvin" <> wrote in message
news:dupsev$3ej$...
>>>> Can anyone easily explain how i in tasking compiler redirect printf to
>>>> the seriel channel by
>>>> replacing putchar ???
>>>
>>> '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.

>
> 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
* 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<0 ? (unsigned char)(*(p)->_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 With Quote
 
Kasper
Guest
Posts: n/a

 
      03-09-2006, 08:03 PM

"Kasper" <r@e@p@z@a@> wrote in message
news:44108009$0$15794$...
>
> "Alex Colvin" <> wrote in message
> news:dupsev$3ej$...
>>>>> Can anyone easily explain how i in tasking compiler redirect printf to
>>>>> the seriel channel by
>>>>> replacing putchar ???
>>>>
>>>> '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.

>>
>> 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

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 With Quote
 
Alex Colvin
Guest
Posts: n/a

 
      03-09-2006, 09:21 PM
>>>>>> Can anyone easily explain how i in tasking compiler redirect printf to
>>>>>> the seriel channel by
>>>>>> replacing putchar ???


>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 ??


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 With Quote
 
Kasper
Guest
Posts: n/a

 
      03-09-2006, 09:24 PM

"Alex Colvin" <> wrote in message
news:duq68h$lkq$...
>>>>>>> Can anyone easily explain how i in tasking compiler redirect printf
>>>>>>> to
>>>>>>> the seriel channel by
>>>>>>> replacing putchar ???

>
>>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 ??

>
> 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.


Myabe the F for funtion and not file ?

Kasper


 
Reply With Quote
 
Alex Colvin
Guest
Posts: n/a

 
      03-09-2006, 11:47 PM
>> on BSD, fputc is documented as a function but putc is a macro.

>Myabe the F for funtion and not file ?


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


--
mac the naïf
 
Reply With Quote
 
Henk-Piet Glas
Guest
Posts: n/a

 
      03-14-2006, 08:26 AM
Kasper wrote:

> (...) understan why it has to be Fputc ??


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:

http://www.tasking.com/support/dsp/DSP56xxx/appnotes/

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

http://www.tasking.com/resources/forum/

Regards,
--
Henk-Piet Glas Support Engineer
-----------------------------------------------------------
E-mail: Altium Software BV
Voice: +31-33-455 85 84 Saturnus 2
Fax: +31-33-455 55 03 3824 ME Amersfoort
WWW: http://www.altium.com The Netherlands
-------[ Altium -- Making Electronics Design Easier ]------
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT. The time now is 06:10 PM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43