Hans - Dulimarta dulimart@egr.msu.edu
Fri Jul 14 06:20:00 GMT 2000

On Fri, 14 Jul 2000, alexperi wrote:

> Date: Fri, 14 Jul 2000 13:52:56 +0100
> From: alexperi <perialex@hotmail.com>
> To: crossgcc@sourceware.cygnus.com
> Subject: sprintf()
> How can I access Serial Port COM1 using sprintf() command?

Two ways which I have used in the past:

1. Let sprintf use "COM1TxBuffer" as its destination string and
   use TransmitInterruptEnable mode of your COM1 controller to
   enable background transmission from COM1TxBuffer.

   [This method works ok as long as your COM1TxBuffer does not overflow]

2. Write my own "fprintf"

   my_fprintf(const char *fmt, ...) {
      va_list parm_ptr;

      va_start (parm_ptr, fmt);
      /* processing which involves converting parameters to
       * stream of chars and send each character to COM1.
       * For example:
       *    write_str (va_arg (parm_ptr, char *));
       *    write_int (va_arg (parm_ptr, int));
      va_end (parm_ptr); 

I think my_fprintf() is more semantically correct that my_sprintf.

Hans Dulimarta, Ph.D.             dulimart@[egr.msu.edu, computer.org]
Visiting Research Associate         http://www.egr.msu.edu/%7edulimart   
                           Ph: (517)432-7589  Fax2Email: (760)281-7691
Elec. & Comp. Engg., Michigan State University, East Lansing, MI 48824

Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

More information about the crossgcc mailing list