cprintf.c File Reference

Custom printf: Implementation More...

#include "..\includes.h"

Macros

#define INC_CPRINTF
 
#define CP_FLAG_CLS   1
 
#define CP_FLAG_CLL   2
 
#define CP_FLAG_STDERR   4
 
#define CPRINTF_NO_ERROR   CPrintfMessages[0]
 
#define CPRINTF_SUCCESS   CPrintfMessages[1]
 
#define CPRINTF_ERROR   CPrintfMessages[2]
 
#define CPRINTF_SKIPPED   CPrintfMessages[3]
 
#define CPRINTF_NO_DEVICE   CPrintfMessages[4]
 
#define CPRINTF_BUFFER_OVERFLOW   CPrintfMessages[5]
 

Functions

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...
 
uint16_t CPrintAnimatedSymbol (char *c, time_t period, size_t size)
 
int32_t CPrintProgressBar (char c, time_t period, size_t length)
 
int32_t CPrintProgressBarText (char c, time_t period, size_t length, char *text)
 

Variables

uint16_t output_device = CPRINTF_NO_OUTPUT
 Select active output device. More...
 
static uint16_t Initialized = 0
 
uint16_t CPrintfFlags = 0
 
char CPrintf_raw_buffer [CPRINTF_BUFFER_SIZE]
 static conversion buffer More...
 
char CPrintf_cleared_buffer [CPRINTF_BUFFER_SIZE]
 
const char * CPrintfMessages []
 

Detailed Description

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

This module contains the custom printf implementation. Depending on available peripheral a formatted print is possible over UART, USB or network

Additional information for using printf: http://processors.wiki.ti.com/index.php/Tips_for_using_printf

Macro Definition Documentation

#define INC_CPRINTF
#define CP_FLAG_CLS   1
#define CP_FLAG_CLL   2
#define CP_FLAG_STDERR   4
#define CPRINTF_NO_ERROR   CPrintfMessages[0]
#define CPRINTF_SUCCESS   CPrintfMessages[1]
#define CPRINTF_ERROR   CPrintfMessages[2]
#define CPRINTF_SKIPPED   CPrintfMessages[3]
#define CPRINTF_NO_DEVICE   CPrintfMessages[4]
#define CPRINTF_BUFFER_OVERFLOW   CPrintfMessages[5]

Function Documentation

uint16_t CPrintf_select_output ( uint16_t  device)
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)
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
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
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
uint16_t CPrintAnimatedSymbol ( char *  c,
time_t  period,
size_t  size 
)
Examples:
Chat.c, DHCPTest.c, DNSTest.c, Echo.c, FTPClient.c, FTPServer.c, HTTPdynamic.c, HTTPjava.c, HTTPsimple.c, Multicast.c, NetTest.c, Ping.c, PServer.c, Receive.c, Send.c, SMTP.c, and Telnet.c.
817 {
818  /***************************************************************************
819  locals
820  ***************************************************************************/
821  char str[3] = "\r*";
822  uint16_t ret = 0;
823  static timeval ProgressTime; /* time stamp */
824  static size_t i = (size_t)0;
825 
826  if ( tv_elapsed (&ProgressTime, (time_t)0, period, TRUE) )
827  {
828  if (++i>=size) i = 0;
829  str[1] = c[i];
830  CPuts (str);
831  ret = 1;
832  }
833  return (ret);
834 }
unsigned short uint16_t
Definition: stdint.h:45
int tv_elapsed(timeval *t, time_t s, time_t u, uint16_t retrigger)
check if given time has elapsed
Definition: timer.c:286
int CPuts(const char *_ptr)
Definition: cprintf.c:399
Definition: timer.h:75
int32_t CPrintProgressBar ( char  c,
time_t  period,
size_t  length 
)
849 {
850  /***************************************************************************
851  locals
852  ***************************************************************************/
853  static timeval ProgressBarTime; /* time stamp */
854  static size_t ProgressBarLength = (size_t)0;
855  static size_t len = (size_t)0;
856 
857  if ((len != length) // length changed
858  || (!period) ) // if period is zero
859  {
860  /***********************************************************************
861  reset locals
862  ***********************************************************************/
863  len = length;
864  ProgressBarTime = GetTimeStamp();
865  ProgressBarLength = (size_t)0;
866  CPuts (CLRLINE); // clear line
867  return (TRUE);
868  }
869 
870  // check elapsed time
871  if ( tv_elapsed (&ProgressBarTime, (time_t)0, period, TRUE) )
872  {
873  CPrintChar (c, 1);
874  if (ProgressBarLength++ >= length)
875  {
876  ProgressBarLength = (size_t)0;
877 
878  /*******************************************************************
879  clear progress bar
880  *******************************************************************/
881  CPuts (CLRLINE);
882 
883  return (TRUE);
884  }
885  }
886  return (FALSE);
887 }
#define CLRLINE
Definition: cprintf.h:171
int tv_elapsed(timeval *t, time_t s, time_t u, uint16_t retrigger)
check if given time has elapsed
Definition: timer.c:286
int CPuts(const char *_ptr)
Definition: cprintf.c:399
Definition: timer.h:75
#define GetTimeStamp()
Definition: timer.h:81
void CPrintChar(const char symbol, size_t count)
Custom print char function.
Definition: cprintf.c:773
int32_t CPrintProgressBarText ( char  c,
time_t  period,
size_t  length,
char *  text 
)
Examples:
Blocksend.c, DNSTest.c, and SMTP.c.
903 {
904  /***************************************************************************
905  locals
906  ***************************************************************************/
907  /* - */
908 
909  if (CPrintProgressBar(c, period, length))
910  {
911  if ((text != NULL) && (*text != 0)) // if text available, print text
912  {
913  CPuts (text);
914  return (TRUE);
915  }
916  }
917 
918  return (FALSE);
919 }
#define NULL
Definition: net.h:126
int CPuts(const char *_ptr)
Definition: cprintf.c:399
int32_t CPrintProgressBar(char c, time_t period, size_t length)
Definition: cprintf.c:848

Variable Documentation

uint16_t output_device = CPRINTF_NO_OUTPUT

Used to select the CPrintf() outputs. Use defines

CPRINTF_USB_OUTPUT 4
CPRINTF_NET_OUTPUT 8
uint16_t Initialized = 0
static
uint16_t CPrintfFlags = 0
char CPrintf_raw_buffer[CPRINTF_BUFFER_SIZE]

Conversion buffer for CPrintf(). If you observe BUFFEROVERFLOW_ERROR errors try to increase CPRINTF_BUFFER_SIZE in cprintf.h or split your CPrintf() function call into several smaller calls.

char CPrintf_cleared_buffer[CPRINTF_BUFFER_SIZE]
const char* CPrintfMessages[]
Initial value:
= {
"",
#define CPRINTF_NO_ERROR
VT100_GREEN" success\r\n"VT100_DEFAULT,
#define CPRINTF_SUCCESS
#define CPRINTF_ERROR
VT100_BLUE" skipped\r\n"VT100_DEFAULT,
#define CPRINTF_SKIPPED
"Device not available!\r\nplease change output channel to CCS:\r\nCPrintf_select_output (CPRINTF_CCS_OUTPUT);\r\nexiting program...",
#define CPRINTF_NO_DEVICE
"CPrintf() buffer overflow error",
#define CPRINTF_BUFFER_OVERFLOW
""
}
#define VT100_DEFAULT
Definition: cprintf.h:150
#define VT100_BLUE
Definition: cprintf.h:146
#define VT100_RED
Definition: cprintf.h:143
#define VT100_GREEN
Definition: cprintf.h:144