1 #include <limits.h> /* Needed for LONG_MAX */
2 #include <sys/stat.h> /* Needed for struct stat st*/
3 #include "dlt.h" /* Needed for DLT Logs */
4 #include <signal.h> /* Signal handling */
8 //! Error code for dlt_user_log_file_complete
9 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE -300
10 //! Error code for dlt_user_log_file_complete
11 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE1 -301
12 //! Error code for dlt_user_log_file_complete
13 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE2 -302
14 //! Error code for dlt_user_log_file_complete
15 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE3 -303
16 //! Error code for dlt_user_log_file_head
17 #define DLT_FILETRANSFER_ERROR_FILE_HEAD -400
18 //! Error code for dlt_user_log_file_data
19 #define DLT_FILETRANSFER_ERROR_FILE_DATA -500
20 //! Error code for dlt_user_log_file_data
21 #define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED -501
22 //! Error code for dlt_user_log_file_end
23 #define DLT_FILETRANSFER_ERROR_FILE_END -600
24 //! Error code for dlt_user_log_file_infoAbout
25 #define DLT_FILETRANSFER_ERROR_INFO_ABOUT -700
26 //! Error code for dlt_user_log_file_packagesCount
27 #define DLT_FILETRANSFER_ERROR_PACKAGE_COUNT -800
30 //!Transfer the complete file as several dlt logs.
31 /**This method transfer the complete file as several dlt logs. At first it will be checked that the file exist.
32 * In the next step some generic informations about the file will be logged to dlt.
33 * Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations.
34 * Then the method dlt_user_log_data will be called with the parameter to log all packages in a loop with some timeout.
35 * At last dlt_user_log_end is called to signal that the complete file transfer was okey. This is important for the plugin of the dlt viewer.
36 * @param fileContext Specific context to log the file to dlt
37 * @param filename Absolute file path
38 * @param deleteFlag Flag if the file will be deleted after transfer. 1->delete, 0->notDelete
39 * @param timeout Timeout in ms to wait between some logs. Important that the FIFO of dlt will not be flooded with to many messages in a short period of time.
40 * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
42 extern int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout);
45 //!This method gives information about the number of packages the file have
46 /**Every file will be divided into several packages. Every package will be logged as a single dlt log.
47 * The number of packages depends on the BUFFER_SIZE.
48 * At first it will be checked if the file exist. Then the file will be divided into
49 * several packages depending on the buffer size.
50 * @param fileContext Specific context to log the file to dlt
51 * @param filename Absolute file path
52 * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
54 extern int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename);
57 //!Logs specific file inforamtions to dlt
58 /**The filename, file size, file serial number and the number of packages will be logged to dlt.
59 * @param fileContext Specific context
60 * @param filename Absolute file path
61 * @return Returns 0 if everything was okey.If there was a failure value < 0 will be returned.
63 extern int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename);
66 //!Transfer the head of the file as a dlt logs.
67 /**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
68 * the file name, the file size, package number the file have and the buffer size.
69 * All these informations are needed from the plugin of the dlt viewer.
70 * See the Mainpages.c for more informations.
71 * @param fileContext Specific context to log the file to dlt
72 * @param filename Absolute file path
73 * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
75 extern int dlt_user_log_file_header(DltContext *fileContext, const char *filename);
78 //!Transfer the content data of a file.
79 /**See the Mainpages.c for more informations.
80 * @param fileContext Specific context to log the file to dlt
81 * @param filename Absolute file path
82 * @param packageToTransfer Package number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
83 * @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
84 * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
86 extern int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int packageToTransfer, int timeout);
90 //!Transfer the end of the file as a dlt logs.
91 /**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number.
92 * This informations is needed from the plugin of the dlt viewer.
93 * See the Mainpages.c for more informations.
94 * @param fileContext Specific context to log the file to dlt
95 * @param filename Absolute file path
96 * @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
97 * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
99 extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename,int deleteFlag);