cprintf.h File Reference

Custom printf: Definitions and Prototypes More...

Macros

#define CPRINTF_CODE_SECTION   ".cprintftext"
 
#define CPRINTF_BUFFER_SIZE   512
 
#define CPRINTF_LINEBUFFER_SIZE   80
 
#define CPRINTF_NO_OUTPUT   0x0
 
#define CPRINTF_CCS_OUTPUT   (1<<COM_DEV_CCS)
 
#define CPRINTF_CCS_BIT   CPRINTF_CCS_OUTPUT
 
#define CPRINTF_UART_OUTPUT   (1<<COM_DEV_UART)
 
#define CPRINTF_UART_BIT   CPRINTF_UART_OUTPUT
 
#define CPRINTF_USB_BIT   0x0
 
#define CPRINTF_NET_BIT   0x0
 
#define CPRINTF_TELNET_BIT   0x0
 
#define CPRINTF_FILE_BIT   0x0
 
#define CPRINTF_CDC_BIT   0x0
 
#define CPRINTF_OUTPUT_MASK
 
#define VT100_TERMINAL   1
 
#define VT100_BLACK   "\x1B[30m"
 
#define VT100_RED   "\x1B[31m"
 
#define VT100_GREEN   "\x1B[32m"
 
#define VT100_YELLOW   "\x1B[33m"
 
#define VT100_BLUE   "\x1B[34m"
 
#define VT100_MAGENTA   "\x1B[35m"
 
#define VT100_CYAN   "\x1B[36m"
 
#define VT100_WHITE   "\x1B[37m"
 
#define VT100_DEFAULT   "\x1B[30m"
 
#define VT100_BLACK_BACK   "\x1B[40m"
 
#define VT100_RED_BACK   "\x1B[41m"
 
#define VT100_GREEN_BACK   "\x1B[42m"
 
#define VT100_YELLOW_BACK   "\x1B[43m"
 
#define VT100_BLUE_BACK   "\x1B[44m"
 
#define VT100_MAGENTA_BACK   "\x1B[45m"
 
#define VT100_CYAN_BACK   "\x1B[46m"
 
#define VT100_WHITE_BACK   "\x1B[47m"
 
#define CLRSCR   "\x1B[2J\x1B[H"
 
#define CLRLINE   "\x1B[79D\x1B[2K"
 
#define CRLF   "\r\n"
 
#define CPRINTF_PROGRESS_COL   52
 
#define CPrintfProgress(s)
 
#define CPrintfProgressVar(s)
 
#define PRINT_SPACER
 
#define CPrintfProgressSuccess()   (CPuts(CPrintfMessages[1]))
 
#define CPrintfProgressError()   (CPuts(CPrintfMessages[2]))
 
#define CPrintfProgressSkipped()   (CPuts(CPrintfMessages[3]))
 

Functions

void CPrintf_select_file (FILE *f)
 
uint16_t CPrintf_select_output (uint16_t device)
 
void CPrintfActivateOutput (void)
 activate all initialized output devices More...
 
int CPuts (const char *_ptr)
 
int CPrintf (const char *_format,...)
 Custom printf function. More...
 
void CPrintChar (const char symbol, size_t count)
 Custom print char function. More...
 

Variables

uint16_t output_device
 Select active output device. More...
 
const char * CPrintfMessages []
 

Detailed Description

                          _         _             _
                       __| |    ___(_) ____ _ __ | |_
                      / _` |   / __| |/ _` | '_ \| __|
                     | (_| | _ \__ \ | (_| | | | | |_
                      \__,_|(_) ___/_|\__, |_| |_|\__|
                     Signalprocessing |___/ Technology
Author
D.SignT GmbH & Co. KG, Claus Hermbusche
Version
2.91
Date
2019-04-17

Macro Definition Documentation

#define CPRINTF_CODE_SECTION   ".cprintftext"
#define CPRINTF_BUFFER_SIZE   512

CPrintf buffer size

#define CPRINTF_LINEBUFFER_SIZE   80
#define CPRINTF_NO_OUTPUT   0x0

define available CPrintf Outputs

#define CPRINTF_CCS_OUTPUT   (1<<COM_DEV_CCS)
#define CPRINTF_CCS_BIT   CPRINTF_CCS_OUTPUT
#define CPRINTF_UART_OUTPUT   (1<<COM_DEV_UART)
#define CPRINTF_UART_BIT   CPRINTF_UART_OUTPUT
#define CPRINTF_USB_BIT   0x0
#define CPRINTF_NET_BIT   0x0
#define CPRINTF_TELNET_BIT   0x0
#define CPRINTF_FILE_BIT   0x0
#define CPRINTF_CDC_BIT   0x0
#define CPRINTF_OUTPUT_MASK
Value:
#define CPRINTF_USB_BIT
Definition: cprintf.h:92
#define CPRINTF_CDC_BIT
Definition: cprintf.h:116
#define CPRINTF_TELNET_BIT
Definition: cprintf.h:104
#define CPRINTF_UART_BIT
Definition: cprintf.h:84
#define CPRINTF_NET_BIT
Definition: cprintf.h:98
#define CPRINTF_FILE_BIT
Definition: cprintf.h:110
#define CPRINTF_CCS_BIT
Definition: cprintf.h:78
#define VT100_TERMINAL   1
#define VT100_BLACK   "\x1B[30m"
#define VT100_GREEN   "\x1B[32m"
#define VT100_YELLOW   "\x1B[33m"
#define VT100_BLUE   "\x1B[34m"
Examples:
FTPClient.c, and Telnet.c.
#define VT100_MAGENTA   "\x1B[35m"
#define VT100_CYAN   "\x1B[36m"
#define VT100_WHITE   "\x1B[37m"
#define VT100_BLACK_BACK   "\x1B[40m"
#define VT100_RED_BACK   "\x1B[41m"
#define VT100_GREEN_BACK   "\x1B[42m"
#define VT100_YELLOW_BACK   "\x1B[43m"
#define VT100_BLUE_BACK   "\x1B[44m"
#define VT100_MAGENTA_BACK   "\x1B[45m"
#define VT100_CYAN_BACK   "\x1B[46m"
#define VT100_WHITE_BACK   "\x1B[47m"
#define CLRSCR   "\x1B[2J\x1B[H"
#define CLRLINE   "\x1B[79D\x1B[2K"
Examples:
Blocksend.c, and SMTP.c.
#define CRLF   "\r\n"
#define CPRINTF_PROGRESS_COL   52
#define CPrintfProgress (   s)
Value:
{ \
int n,r=CPuts(s); \
CPrintChar('.',n); \
}
void CPrintChar(const char symbol, size_t count)
Custom print char function.
Definition: cprintf.c:773
#define CPRINTF_PROGRESS_COL
Definition: cprintf.h:218
int CPuts(const char *_ptr)
Definition: cprintf.c:399

print string with trailing dots ".....". The dots will end at line CPRINTF_PROGRESS_COL

1 CPrintfProgress (" Enable interrupts ");
Examples:
Blocksend.c, Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, Ping2.c, PServer.c, Receive.c, Send.c, SMTP.c, SNTPTest.c, and Telnet.c.
#define CPrintfProgressVar (   s)
Value:
{ \
int n,r=CPrintf s ; \
CPrintChar('.',n); \
}
void CPrintChar(const char symbol, size_t count)
Custom print char function.
Definition: cprintf.c:773
#define CPRINTF_PROGRESS_COL
Definition: cprintf.h:218
int CPrintf(const char *_format,...)
Custom printf function.
Definition: cprintf.c:708

print variadic string with trailing dots ".....". The dots will end at line CPRINTF_PROGRESS_COL.
use with double parentheses:

1 CPrintfProgressVar ((" Enable interrupt %d ", interrupt));
#define PRINT_SPACER
Value:
{ \
CPrintChar ('-',58); \
CPuts (CRLF); \
}
#define CRLF
Definition: cprintf.h:214
#define CPrintfProgressSuccess ( )    (CPuts(CPrintfMessages[1]))

print progress success message. On VT100 terminals this message is printed in green.

1 CPrintfProgressSuccess()
Examples:
Blocksend.c, Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, Ping2.c, PServer.c, Receive.c, Send.c, SMTP.c, SNTPTest.c, and Telnet.c.
#define CPrintfProgressError ( )    (CPuts(CPrintfMessages[2]))

print progress error message. On VT100 terminals this message is printed in red; on non VT100 terminals the stderr stream is used.

1 CPrintfProgressError()
#define CPrintfProgressSkipped ( )    (CPuts(CPrintfMessages[3]))

print progress skipped message. On VT100 terminals this message is printed in blue; on non VT100 terminals the stdout stream is used.

1 CPrintfProgressSkipped()

Function Documentation

void CPrintf_select_file ( FILE *  f)
uint16_t CPrintf_select_output ( uint16_t  device)
Examples:
Blocksend.c, Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, Ping2.c, PServer.c, Receive.c, Send.c, SMTP.c, SNTPTest.c, and Telnet.c.
207 {
208  /***************************************************************************
209  locals
210  ***************************************************************************/
211  uint16_t old_device = output_device;
212 
213  if ( device == 0 )
214  {
215  /***********************************************************************
216  output disabled
217  ***********************************************************************/
218  output_device = device;
219  return (old_device);
220  }
221 
222  if ( (device & CPRINTF_OUTPUT_MASK) == 0 )
223  {
224  /***********************************************************************
225  device not available
226  ***********************************************************************/
228  }
229 
231 
232 #ifdef CPRINTF_CCS_AVAILABLE
234  {
235  if (!(Initialized & CPRINTF_CCS_OUTPUT))
236  {
237  /*******************************************************************
238  CCS output needs no initialization
239  *******************************************************************/
241  }
242  }
243 #endif // CPRINTF_CCS_AVAILABLE
244 
245 #ifdef CPRINTF_UART_AVAILABLE
247  {
248  if (!(Initialized & CPRINTF_UART_OUTPUT))
249  {
250  /*******************************************************************
251  initialize UART
252  *******************************************************************/
253  if (UartInitialize())
254  {
255 #ifndef FLASH_RUN
256  puts ("couldn't get a UART handle!\r\nexiting program\r\n");
257 #endif
258  prg_exit ("InitializeUART() failed");
259  }
260  else
261  {
262 #ifndef FLASH_RUN
263  puts (" UART successfully initialized!\r\n");
264  puts (printf_uart_str);
265 #endif
266  }
268  }
269  }
270 #endif // CPRINTF_UART_AVAILABLE
271 
272 #ifdef CPRINTF_USB_AVAILABLE
273  if (output_device & CPRINTF_USB_OUTPUT)
274  {
275  if (!(Initialized & CPRINTF_USB_OUTPUT))
276  {
277  /*******************************************************************
278  USB connection must be initialized prior to this function
279  *******************************************************************/
280  // if ( UsbInitialize () )
281  // {
282  // prg_exit(CPRINTF_DEVICE_ERROR);
283  // }
284  Initialized |= CPRINTF_USB_OUTPUT;
285  }
286  }
287 
288 #endif // CPRINTF_USB_AVAILABLE
289 #ifdef CPRINTF_CDC_AVAILABLE
290  if (output_device & CPRINTF_CDC_OUTPUT)
291  {
292  if (!(Initialized & CPRINTF_CDC_OUTPUT))
293  {
294  puts (" USB successfully initialized!\r\n");
295  puts (printf_cdc_str);
296  if ( BoardCdcInit () )
297  {
298  prg_exit("BoardCdcInit() failed");
299  }
300  Initialized |= CPRINTF_CDC_OUTPUT;
301  }
302  }
303 
304 #endif // CPRINTF_USB_AVAILABLE
305 
306 #ifdef CPRINTF_NET_AVAILABLE
307  if (output_device & CPRINTF_NET_OUTPUT)
308  {
309  if (!(Initialized & CPRINTF_NET_OUTPUT))
310  {
311  /*******************************************************************
312  check if stack is initialized
313  *******************************************************************/
314  if (!net_initialized)
315  {
316  prg_exit(CPRINTF_NET_NOT_INITIALIZED);/* Stack not initialized*/
317  }
318 
319  /*******************************************************************
320  initialize Net connection
321  *******************************************************************/
322  if ( InitializeNetIO())
323  {
325  }
326  else
327  {
328  puts (" NETPrintf successfully initialized!\r\n\n please connect a UDP terminal to see CPrintf outputs\r\n");
329  }
330  Initialized |= CPRINTF_NET_OUTPUT;
331  }
332  }
333 #endif // CPRINTF_NET_AVAILABLE
334 
335 #ifdef CPRINTF_TELNET_AVAILABLE
336  if (output_device & CPRINTF_TELNET_OUTPUT)
337  {
338  if (!(Initialized & CPRINTF_TELNET_OUTPUT))
339  {
340  /*******************************************************************
341  Telnet connection must be initialized prior to this function
342  *******************************************************************/
343  // if ( TelnetInitialize () )
344  // {
345  // prg_exit(CPRINTF_DEVICE_ERROR);
346  // }
347  Initialized |= CPRINTF_TELNET_OUTPUT;
348  }
349  }
350 
351 #endif // CPRINTF_TELNET_AVAILABLE
352 #ifdef CPRINTF_FILE_AVAILABLE
353  if (output_device & CPRINTF_FILE_OUTPUT)
354  {
355  if (!(Initialized & CPRINTF_FILE_OUTPUT))
356  {
357  /*******************************************************************
358  File must be initialized prior to this function
359  *******************************************************************/
360  // if ( FileInitialize () )
361  // {
362  // prg_exit(CPRINTF_DEVICE_ERROR);
363  // }
364  Initialized |= CPRINTF_FILE_OUTPUT;
365  }
366  }
367  else
368  {
369  /***********************************************************************
370  File output disabled
371  ***********************************************************************/
372  cprintf_file = NULL;
373  }
374 #endif // CPRINTF_TELNET_AVAILABLE
375 
376  return (old_device);
377 }
static uint16_t Initialized
Definition: cprintf.c:112
#define prg_exit(s)
Definition: Common.h:267
uint16_t output_device
Select active output device.
Definition: cprintf.c:110
#define CPRINTF_CCS_OUTPUT
Definition: cprintf.h:77
#define NULL
Definition: net.h:126
unsigned short uint16_t
Definition: stdint.h:45
char * printf_uart_str
#define CPRINTF_NO_DEVICE
int UartInitialize()
Initialize UART.
Definition: uartio.c:126
#define CPRINTF_OUTPUT_MASK
Definition: cprintf.h:122
uint32_t net_initialized
#define CPRINTF_UART_OUTPUT
Definition: cprintf.h:83
void CPrintfActivateOutput ( void  )
Parameters
-
Returns
-
388 {
390 }
static uint16_t Initialized
Definition: cprintf.c:112
uint16_t output_device
Select active output device.
Definition: cprintf.c:110
int CPuts ( const char *  _ptr)
Examples:
Blocksend.c, Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, Ping2.c, PServer.c, Receive.c, Send.c, SMTP.c, SNTPTest.c, and Telnet.c.
400 {
401  /***************************************************************************
402  locals
403  ***************************************************************************/
404  int cnt = 0;
405  char *src;
406  char *dest;
407 #if (defined(CPRINTF_CCS_AVAILABLE)||defined(CPRINTF_FILE_AVAILABLE))
408  FILE *out=NULL;
409 #endif
410 
411  if ( output_device == 0 )
412  {
413  /***********************************************************************
414  output disabled
415  ***********************************************************************/
416  return (cnt);
417  }
418  CPrintfFlags = 0;
419 
420  /***************************************************************************
421  parse buffer for VT100 codes and create cleared buffer for non-VT100
422  terminals
423  note: not all VT100 commands are implemented!
424  ***************************************************************************/
425  src = (char *)_ptr;
426  dest = CPrintf_cleared_buffer;
427  cnt = strlen (_ptr);
428  while ( *src )
429  {
430 #ifdef VT100_TERMINAL
431  /***********************************************************************
432  escape sequence
433  ***********************************************************************/
434  if ( *src == '\x1B' )
435  {
436  src++;
437 
438  /*******************************************************************
439  detect [
440  *******************************************************************/
441  if ( *src == '[' )
442  {
443  src++;
444 
445  /***************************************************************
446  detect 2
447  ***************************************************************/
448  if ( *src == '2' )
449  {
450  src++;
451  if ( *src == 'K' )
452  {
453  src++;
454  continue;
455  } // if
456  if ( *src == 'J' )
457  {
458  src++;
459  CPrintfFlags |= CP_FLAG_CLS; // clear screen detected
460  continue;
461  } // if
462  src++;
463  src++;
464  continue;
465  } // if
466 
467  /***************************************************************
468  set cursor position code
469  ***************************************************************/
470  if ( *src == 'H' )
471  {
472  src++;
473  continue;
474  } // if
475  if ( src[3] == 'H' )
476  {
477  /***********************************************************
478  skip command
479  ***********************************************************/
480  src+=4;
481  continue;
482  }
483  if ( src[4] == 'H' )
484  {
485  /***********************************************************
486  skip command
487  ***********************************************************/
488  src+=5;
489  continue;
490  }
491  if ( src[5] == 'H' )
492  {
493  /***********************************************************
494  skip command
495  ***********************************************************/
496  src+=6;
497  continue;
498  }
499 
500  if ( src[2] == 'D' )
501  {
502  /***********************************************************
503  skip command
504  ***********************************************************/
505  src+=3;
506  CPrintfFlags |= CP_FLAG_CLL; // clear line detected
507  continue;
508  }
509 
510  /***************************************************************
511  detect 3 or 4, VT100 color codes
512  ***************************************************************/
513  if ( ( *src == '3' ) || ( *src == '4' ) )
514  {
515  if (src[1] == '1')
516  {
517  /*******************************************************
518  red color requested, switch to stderr
519  *******************************************************/
520  CPrintfFlags |= CP_FLAG_STDERR; // stderr detected
521 
522  }
523 
524  /***********************************************************
525  skip command
526  ***********************************************************/
527  src+=3;
528  continue;
529  }
530 
531  continue;
532  }
533  continue;
534  } // if
535 
536  /***********************************************************************
537  back space
538  ***********************************************************************/
539  if ( *src == '\b' )
540  {
541  src++;
542  continue;
543  } // if
544 #endif
545  *dest++ = *src++;
546  } // if
547  *dest=0;
548 
549  /***************************************************************************
550  write string
551  ***************************************************************************/
552 #ifdef CPRINTF_CCS_AVAILABLE
554  {
555  /***********************************************************************
556  output to CCS
557  ***********************************************************************/
558  if (CPrintfFlags & CP_FLAG_STDERR) // stderr detected
559  {
560  out = stderr;
561  }
562  else
563  {
564  out = stdout;
565  }
566 #ifndef FLASH_RUN
567  if (CPrintfFlags & CP_FLAG_CLS) // clear screen detected
568  {
569  /*******************************************************************
570  clear screen command detected. use line feeds instead
571  *******************************************************************/
572  puts ("\r\n\n\n");
573  fflush (out);
574  }
575  if (CPrintfFlags & CP_FLAG_CLL) // clear line detected
576  {
577  /*******************************************************************
578  clear line command detected. use line feed instead
579  *******************************************************************/
580  puts ("\r");
581  fflush (out);
582  }
584  {
585  fprintf (out, CPrintf_cleared_buffer);
586  fflush (out);
587  }
588 #else
589  (void)out;
590 
591 #endif
592  }
593 #endif // CPRINTF_CCS_AVAILABLE
594 
595 #ifdef CPRINTF_UART_AVAILABLE
597  {
598  /***********************************************************************
599  output to UART
600  ***********************************************************************/
601  UartWriteStr ((char *)_ptr);
602  }
603  // (void)cls_detect;
604  // (void)stderr_detect;
605 
606 #endif // CPRINTF_UART_AVAILABLE
607 
608 #ifdef CPRINTF_CDC_AVAILABLE
609  if (output_device & CPRINTF_CDC_OUTPUT)
610  {
611  /***********************************************************************
612  output to UART
613  ***********************************************************************/
614  BoardCdcWriteString ((char *)_ptr);
615  }
616  // (void)cls_detect;
617  // (void)stderr_detect;
618 
619 #endif // CPRINTF_UART_AVAILABLE
620 
621 #ifdef CPRINTF_USB_AVAILABLE
622  if (output_device & CPRINTF_USB_OUTPUT)
623  {
624  /***********************************************************************
625  output to USB
626  ***********************************************************************/
627  if (CPrintfFlags & CP_FLAG_CLS ) // clear screen detected
628  {
629  /*******************************************************************
630  clear screen command detected. use line feeds instead
631  *******************************************************************/
632  UsbioWriteStr ( "\r\n\n\n");
633  }
634  UsbioWriteStr ( CPrintf_cleared_buffer);
635  }
636 #endif // CPRINTF_USB_AVAILABLE
637 
638 #ifdef CPRINTF_NET_AVAILABLE
639  if (output_device & CPRINTF_NET_OUTPUT)
640  {
641  /***********************************************************************
642  output to network connection
643  ***********************************************************************/
644  if (_link )
645  {
646  NetWriteFormattedStr ();
647  }
648  }
649 #endif // CPRINTF_NET_AVAILABLE
650 
651 #ifdef CPRINTF_TELNET_AVAILABLE
652  if (output_device & CPRINTF_TELNET_OUTPUT)
653  {
654  /***********************************************************************
655  output to network connection
656  ***********************************************************************/
657  if (_link )
658  {
659  TelnetWriteStr ((char *)_ptr);
660  }
661  }
662 #endif // CPRINTF_TELNET_AVAILABLE
663 
664 #ifdef CPRINTF_FILE_AVAILABLE
665  if (output_device & CPRINTF_FILE_OUTPUT)
666  {
667  /***********************************************************************
668  output to file
669  ***********************************************************************/
670  out = cprintf_file;
671  if (out )
672  {
673  if (CPrintfFlags & CP_FLAG_CLS) // clear screen detected
674  {
675  /***************************************************************
676  clear screen command detected. use line feeds instead
677  ***************************************************************/
678  fprintf (out, "\r\n\n\n");
679  fflush (out);
680  }
681  if (CPrintfFlags & CP_FLAG_CLL) // clear line detected
682  {
683  /***************************************************************
684  clear line command detected. use line feed instead
685  ***************************************************************/
686  fprintf (out, CRLF);
687  fflush (out);
688  }
690  {
691  fprintf ( out, CPrintf_cleared_buffer);
692  fflush (out);
693  }
694  }
695  }
696 #endif // CPRINTF_FILE_AVAILABLE
697 
698  return (cnt);
699 }
uint16_t output_device
Select active output device.
Definition: cprintf.c:110
volatile uint16_t _link
Definition: BoardSpecific.c:143
#define CPRINTF_CCS_OUTPUT
Definition: cprintf.h:77
void TelnetWriteStr(const char *buffer)
append a zero terminated string to telnet write buffer
Definition: telnetio.c:213
#define NULL
Definition: net.h:126
#define CRLF
Definition: cprintf.h:214
#define CP_FLAG_STDERR
Definition: cprintf.c:117
char CPrintf_cleared_buffer[CPRINTF_BUFFER_SIZE]
Definition: cprintf.c:129
#define CP_FLAG_CLL
Definition: cprintf.c:116
uint16_t CPrintfFlags
Definition: cprintf.c:114
#define CP_FLAG_CLS
Definition: cprintf.c:115
void UartWriteStr(char *s)
Definition: uartio.c:175
#define CPRINTF_UART_OUTPUT
Definition: cprintf.h:83
int CPrintf ( const char *  _format,
  ... 
)
Parameters
_format- format string
Returns
amount of printed characters
Examples:
Blocksend.c, Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, Ping2.c, PServer.c, Receive.c, Send.c, SMTP.c, SNTPTest.c, and Telnet.c.
709 {
710  /***************************************************************************
711  locals
712  ***************************************************************************/
713  va_list argptr;
714  int cnt = 0;
715 
716  if ( output_device == 0 )
717  {
718  /***********************************************************************
719  output disabled
720  ***********************************************************************/
721  return (cnt);
722  }
723  CPrintfFlags = 0;
724 
725  /***************************************************************************
726  initializes variable argument list
727  ***************************************************************************/
728 #pragma diag_suppress 238
729  va_start (argptr, _format);
730 #pragma diag_default 238
731 
732  /***************************************************************************
733  print to buffer
734  ***************************************************************************/
735  cnt = vsprintf (CPrintf_raw_buffer, _format, argptr);
736 
737  /***************************************************************************
738  vsprintf returns the amount of printed characters. The user buffer size is
739  limited to CPRINTF_BUFFER_SIZE. Check for buffer overflow and exit if
740  necessary.
741  ***************************************************************************/
742  if (cnt > CPRINTF_BUFFER_SIZE)
743  {
746  }
747  if ( cnt <= 0 )
748  {
749  /***********************************************************************
750  nothing to print
751  ***********************************************************************/
752  va_end(argptr);
753  return (cnt);
754  }
755 
757 
758  /***************************************************************************
759  end variable argument list
760  ***************************************************************************/
761  va_end(argptr);
762 
763  return (cnt);
764 }
#define prg_exit(s)
Definition: Common.h:267
uint16_t output_device
Select active output device.
Definition: cprintf.c:110
uint32_t exit_code
Definition: Common.c:104
#define CPRINTF_BUFFER_SIZE
Definition: cprintf.h:67
#define BUFFEROVERFLOW_ERROR
Definition: Common.h:383
int CPuts(const char *_ptr)
Definition: cprintf.c:399
uint16_t CPrintfFlags
Definition: cprintf.c:114
char CPrintf_raw_buffer[CPRINTF_BUFFER_SIZE]
static conversion buffer
Definition: cprintf.c:128
#define CPRINTF_BUFFER_OVERFLOW
void CPrintChar ( const char  symbol,
size_t  count 
)
Parameters
symbol- character to print
count- repeat count
Returns
nothing
Examples:
DNSTest.c.
774 {
775  /***************************************************************************
776  locals
777  ***************************************************************************/
778  // size_t i;
779 
780  if ( output_device == 0 )
781  {
782  /***********************************************************************
783  output disabled
784  ***********************************************************************/
785  return;
786  }
787 
789 
790  CPrintfFlags = 0;
791 
792  // i = count;
793  memset(CPrintf_raw_buffer, (int)symbol, count);
794  CPrintf_raw_buffer[count] = 0;
795 
796  // while ( i-- )
797  // {
798  // CPrintf_raw_buffer[i] = CPrintf_cleared_buffer[i] = symbol;
799  // } // if
800 
802 }
#define prg_exit(s)
Definition: Common.h:267
uint16_t output_device
Select active output device.
Definition: cprintf.c:110
#define CPRINTF_BUFFER_SIZE
Definition: cprintf.h:67
int CPuts(const char *_ptr)
Definition: cprintf.c:399
uint16_t CPrintfFlags
Definition: cprintf.c:114
char CPrintf_raw_buffer[CPRINTF_BUFFER_SIZE]
static conversion buffer
Definition: cprintf.c:128
#define CPRINTF_BUFFER_OVERFLOW

Variable Documentation

output_device

Used to select the CPrintf() outputs. Use defines

CPRINTF_USB_OUTPUT 4
CPRINTF_NET_OUTPUT 8
const char* CPrintfMessages[]