PrintToUart

 

#include <stdio.h>

#include <string.h>

#include <stdarg.h>

#include "m2m_type.h"

#include "m2m_hw_api.h"

 

void PrintToUart ( const char *fmt, ... )

{

            INT32 sent;

            va_list arg;

            CHAR buf[256];

 

            M2M_T_HW_UART_HANDLE uart_handle = M2M_HW_UART_HANDLE_INVALID;

 

            va_start(arg, fmt);

            vsnprintf(buf, 256, fmt, arg);

 

            /* Get a UART handle first */

            uart_handle = m2m_hw_uart_open();

 

            if (uart_handle != M2M_HW_UART_HANDLE_INVALID)

             {

               m2m_hw_uart_write(uart_handle, buf, strlen(buf), &sent);

               m2m_hw_uart_write(uart_handle, "\r\n", 2, &sent);

                   m2m_hw_uart_close(uart_handle);

             }

 

            va_end(arg);

}