1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/**
* @licence app begin@
* Copyright (C) 2012 BMW AG
*
* This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
*
* Contributions are licensed to the GENIVI Alliance under one or more
* Contribution License Agreements.
*
* \copyright
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* \file dlt_filetransfer.h
* For further information see http://www.genivi.org/.
* @licence end@
*/
#include <limits.h> /* Needed for LONG_MAX */
#include <sys/stat.h> /* Needed for struct stat st*/
#include "dlt.h" /* Needed for DLT Logs */
#include <signal.h> /* Signal handling */
#include "errno.h"
//! Error code for dlt_user_log_file_complete
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE -300
//! Error code for dlt_user_log_file_complete
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE1 -301
//! Error code for dlt_user_log_file_complete
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE2 -302
//! Error code for dlt_user_log_file_complete
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE3 -303
//! Error code for dlt_user_log_file_head
#define DLT_FILETRANSFER_ERROR_FILE_HEAD -400
//! Error code for dlt_user_log_file_data
#define DLT_FILETRANSFER_ERROR_FILE_DATA -500
//! Error code for dlt_user_log_file_data
#define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED -501
//! Error code for dlt_user_log_file_end
#define DLT_FILETRANSFER_ERROR_FILE_END -600
//! Error code for dlt_user_log_file_infoAbout
#define DLT_FILETRANSFER_ERROR_INFO_ABOUT -700
//! Error code for dlt_user_log_file_packagesCount
#define DLT_FILETRANSFER_ERROR_PACKAGE_COUNT -800
//!Transfer the complete file as several dlt logs.
/**This method transfer the complete file as several dlt logs. At first it will be checked that the file exist.
* In the next step some generic informations about the file will be logged to dlt.
* Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations.
* Then the method dlt_user_log_data will be called with the parameter to log all packages in a loop with some timeout.
* 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.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @param deleteFlag Flag if the file will be deleted after transfer. 1->delete, 0->notDelete
* @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.
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout);
//!This method gives information about the number of packages the file have
/**Every file will be divided into several packages. Every package will be logged as a single dlt log.
* The number of packages depends on the BUFFER_SIZE.
* At first it will be checked if the file exist. Then the file will be divided into
* several packages depending on the buffer size.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename);
//!Logs specific file inforamtions to dlt
/**The filename, file size, file serial number and the number of packages will be logged to dlt.
* @param fileContext Specific context
* @param filename Absolute file path
* @return Returns 0 if everything was okey.If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename);
//!Transfer the head of the file as a dlt logs.
/**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
* the file name, the file size, package number the file have and the buffer size.
* All these informations are needed from the plugin of the dlt viewer.
* See the Mainpages.c for more informations.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @param alias Alias for the file. An alternative name to show in the receiving end
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename, const char *alias);
//!Transfer the head of the file as a dlt logs.
/**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
* the file name, the file size, package number the file have and the buffer size.
* All these informations are needed from the plugin of the dlt viewer.
* See the Mainpages.c for more informations.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_header(DltContext *fileContext, const char *filename);
//!Transfer the content data of a file.
/**See the Mainpages.c for more informations.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @param packageToTransfer Package number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
* @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.
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int packageToTransfer, int timeout);
//!Transfer the end of the file as a dlt logs.
/**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number.
* This informations is needed from the plugin of the dlt viewer.
* See the Mainpages.c for more informations.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
* @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename,int deleteFlag);
|