/************************************************************************* MODULE : $RCSfile: targsend.c $ PART OF : CTC/LIBRARY Host-Target support VERSION : $Revision: 1.4 $, $Date: 2016/10/17 13:43:32 $ AUTHOR : $Author: olavi $ LAST EDITED : 13.10.2016/op DESCRIPTION : targsend.c gives a MODEL IMPLEMENTATION for the ctc_send_data() function. The implementation uses some normal C library functions. A fixed-named local file MON.txt at the target disk is used. You can modify this implementation as needed/possible. Copyright (c) 2007-2013 Testwell Oy Copyright (c) 2013-2016 Verifysoft Technology GmbH **************************************************************************/ /* Revision history $Log: targsend.c $ Revision 1.4 2016/10/17 13:43:32 olavi - #ifdef __CTC__ #error ... #endif guard on file's instrumentation changed to #pragma CTC SKIP ... #pragma CTC ENDSKIP (works better...) Revision 1.3 2011/07/23 11:26:28 seppo - Added #ifdef __CTC__ guard to prevent compilation with CTC++ Revision 1.2 2009/11/18 14:35:29 seppo - Some comment additions and rewordings Revision 1.1 2007/05/17 14:17:36 olavi Initial revision */ /* even if attempted, do not instrument this file */ #ifdef __CTC__ #pragma CTC SKIP #endif /*********************** STANDARD LIBRARY INCLUDES ***********************/ #include #include #include /************************* APPLICATION INCLUDES **************************/ #include "ctctypes.h" #include "targdata.h" /*************************** PUBLIC FUNCTIONS ****************************/ /************************************************************************* FUNCTION : ctc_send_data PURPOSE : This is the function, which is called to transmit the collected coverage data from the target main memory to "somewhere". That "somewhere" can be e.g. a communication line to the host computer (having a program running to receive the data), or it can be a local text file at the target. Here is a model implementation which writes the data to a text file MON.txt on the target machine disk. Possibly you can use this, either "as is" or as a starting point. See the readme.txt for more detailed discussion of this subject. ARGUMENTS : None RETURNS : Nothing *************************************************************************/ void ctc_send_data(void) { FILE* fp; int c; int charcount = 0; time_t time_now; char* asc_time; /* Opened in APPEND mode (important to allow many cumulative write-outs to the same file). Default name MON.txt. No error recovery! */ if ((fp = fopen("MON.txt", "a")) != NULL) { /* Some remarks of this algorithm: - Header line outputting is optional, but may help human reader. If you can't use /asctime() and /strlen(), do not write the header (comment) line at all... - Writing the '\n' chars for line-folding can be omitted, but they help reviewing, if needed to view by a text editor. - If you find it more efficient, you can collect the chars to a buffer and write the whole buffer at once in a larger junk. */ time_now = time(NULL); asc_time = asctime(localtime((time_t*)&time_now)); *(asc_time + strlen(asc_time) - 1) = '\0'; /* remove the trailing '\n' */ fprintf(fp, "\nDump of CTC++ coverage data from target memory at %s:\n\n", asc_time); ctc_prepare_upload(); /* start from first registered source file */ while ((c = ctc_get_character()) > 0) { fputc(c, fp); if ((++charcount % 78) == 0) { fputc('\n', fp); /* split long lines... */ } } fputc('\n', fp); /* at the end still... */ fclose(fp); } } #ifdef __CTC__ #pragma CTC ENDSKIP #endif /* EOF $RCSfile: targsend.c $ */