Subj : Need to write putchar for embedded system To : comp.lang.c,comp.programming From : Confused User Date : Thu Jun 30 2005 10:29 pm I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business was quite insestual for while wasn't it? I need to write putchar so that printf can function properly. Anyway, the compiler comes with just a shell of a putchar routine. It literally returns the character you passed to it and nothing else. That is not why it's a piece of crap, although they could have at least supplied something that writes to the serial port. So, I already have a serial port interrupt routing with circular buffers (in/out) and a function call (SendData()) that copies a data from a pointer argument and manages the circular buffer. So, I want to have my putchar routine call SendData. I noticed from looking around that putchar returns EOF if unsuccessful. EOF is defined as -1 in the compiler header file. Therefore, it occurs to me that putchar can only be used for ASCII data. This is OK, I just need to make sure I have that right. Because, binary data could include -1 right? That means I should never use it alone to send binary data. If so, is this true for the PC? After all, it's counterpart, getchar retrives binary scan codes from the keyboard unless they have already been converted to ASCII characters before they get to that level. I would guess the only time getchar should return EOF is if the transmit buffer is full. My SendData() function already is set to return a fail code if the buffer is full. putchar can pass this on to printf (of course I have to change SendData() to use EOF as a fail code). As an embedded programmer, I am not real familiar with what normal pass/fail return codes should be. The high level languages were developed around full OS systems (Unix etc.) and then seem to have migrated to the embedded world leaving some us without familiarity of conventions. Enough rambling.... Just looking for any constructive input. Elvis .