1 /** \mainpage DLT Filetransfer Main documentation page
3 \section Introduction Introduction
4 DLT Filetransfer enables the feature to store the binary data of a file to the automotive dlt log. The file will
5 be read in binary mode and put as payload to a DLT_INFO log. With a special plugin of the dlt viewer, you can
6 extract the file from the trace and save it to your hard disk.
9 \section Protocol Protocol
10 The file transfer is at least one single transaction. This transaction consist of three main types of packages:
12 \li one or more data packages
15 The following section explains more about the content of each package.
17 \subsection Header Header Package
18 Every filetransfer must begin with the header package using:
20 int dlt_user_log_file_header(DltContext *fileContext,const char *filename)
22 Here's the conent of the header package:
24 |----------------------------------------------------|
26 |----------------------------------------------------|
27 | fileserialnumber | Inode of the file used as file serialnumber
28 |----------------------------------------------------|
29 | filename | Use the absolute filepath to the file
30 |----------------------------------------------------|
31 | filesize | Filesize of the file
32 |----------------------------------------------------|
33 | file creation date | Creation date of the file
34 |----------------------------------------------------|
35 | number of packages | Counted packages which will be transferred in the data packages
36 |----------------------------------------------------|
37 | BUFFER_SIZE | Defined buffer size to reconstruct the file
38 |----------------------------------------------------|
40 |----------------------------------------------------|
43 \subsection Data Data Package
44 After the header package was sent, at least one or more data packages can be send using:
46 int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int packageToTransfer, int timeout)
48 Here's the conent of the data package:
50 |----------------------------------------------------|
52 |----------------------------------------------------|
53 | fileserialnumber | Inode of the file used as file serialnumber
54 |----------------------------------------------------|
55 | PackageNumber | Transferred package
56 |----------------------------------------------------|
57 | Data | Payload containing data
58 |----------------------------------------------------|
60 |----------------------------------------------------|
64 \subsection End End Package
65 After all data packages were sent, the end package must be sent to indicate that the filetransfer is over using:
67 int dlt_user_log_file_end(DltContext *fileContext,const char *filename,int deleteFlag)
69 Here's the conent of the end package:
71 |----------------------------------------------------|
73 |----------------------------------------------------|
74 | fileserialnumber | Inode of the file
75 |----------------------------------------------------|
77 |----------------------------------------------------|
79 \subsection File information
80 The library offers the user the possibility to log informations about a file using the following method without transferring the file itself using:
82 dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
84 Here is the content of the information package:
86 |----------------------------------------------------|
88 |----------------------------------------------------|
89 | fileserialnumber | Inode of the file used as file serialnumber
90 |----------------------------------------------------|
91 | filename | Use the absolute filepath to the file
92 |----------------------------------------------------|
93 | filesize | Filesize of the file
94 |----------------------------------------------------|
95 | file creation date | Creation date of the file
96 |----------------------------------------------------|
97 | number of packages | Counted packages which will be transferred in the data packages
98 |----------------------------------------------------|
100 |----------------------------------------------------|
103 \subsection File transfer error
105 //! Error code for dlt_user_log_file_complete
106 #define ERROR_FILE_COMPLETE -300
107 //! Error code for dlt_user_log_file_complete
108 #define ERROR_FILE_COMPLETE1 -301
109 //! Error code for dlt_user_log_file_complete
110 #define ERROR_FILE_COMPLETE2 -302
111 //! Error code for dlt_user_log_file_complete
112 #define ERROR_FILE_COMPLETE3 -303
113 //! Error code for dlt_user_log_file_head
114 #define ERROR_FILE_HEAD -400
115 //! Error code for dlt_user_log_file_data
116 #define ERROR_FILE_DATA -500
117 //! Error code for dlt_user_log_file_data
118 #define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED -501
119 //! Error code for dlt_user_log_file_end
120 #define ERROR_FILE_END -600
121 //! Error code for dlt_user_log_file_infoAbout
122 #define ERROR_INFO_ABOUT -700
123 //! Error code for dlt_user_log_file_packagesCount
124 #define ERROR_PACKAGE_COUNT -800
126 If an error happens during file transfer, the library will execute the mehtod:
128 void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filename, int errorCode)
130 Here is the content of the error package:
132 |----------------------------------------------------|
133 | FLER | Package flag
134 |----------------------------------------------------|
135 | error code | see error codes above
136 |----------------------------------------------------|
137 | linux error code | standard linux error code
138 |----------------------------------------------------|
139 | fileserialnumber | Inode of the file used as file serialnumber
140 |----------------------------------------------------|
141 | filename | Use the absolute filepath to the file
142 |----------------------------------------------------|
143 | filesize | Filesize of the file
144 |----------------------------------------------------|
145 | file creation date | Creation date of the file
146 |----------------------------------------------------|
147 | number of packages | Counted packages which will be transferred in the data packages
148 |----------------------------------------------------|
149 | FLER | Package flag
150 |----------------------------------------------------|
152 If the file doesn't exist, the conent of the error package is a little bit different:
154 |----------------------------------------------------|
155 | FLER | Package flag
156 |----------------------------------------------------|
157 | error code | see error codes above
158 |----------------------------------------------------|
159 | linux error code | standard linux error code
160 |----------------------------------------------------|
161 | filename | Use the absolute filepath to the file
162 |----------------------------------------------------|
163 | FLER | Package flag
164 |----------------------------------------------------|
167 \section Using Using DLT Filetransfer
168 There are two ways to use the filetransfer
169 \li Automatic filetransfer in one step
170 \li Header, data and end package order handeld by the user
172 \subsection Automatic Automatic
174 \li dlt_user_log_file_complete
176 The method needs the following arguments:
177 \li fileContext -> Context for logging the file to dlt
178 \li filename -> Use the absolute file path to the file
179 \li deleteFlag -> Flag if the file will be deleted after transfer. 1->delete, 0->notDelete
180 \li timeout -> Deprecated.
182 The order of the packages is to send at first the header, then one or more data packages (depends on the filesize) and in the end the end package.
183 The advantage of this method is, that you must not handle the package ordering by your own.
185 Within dlt_user_log_file_complete the free space of the user buffer will be checked. If the free space of the user buffer < 50% then the
186 actual package won't be transferred and a timeout will be executed.
188 If the daemon crashes and the user buffer is full -> the automatic method is in an endless loop.
190 \subsection Manual Manual
191 Manual starting filetransfer with the following commands:
192 \li dlt_user_log_file_head | Transfers only the header of the file
193 \li dlt_user_log_file_data | Transfers only one single package of a file
194 \li dlt_user_log_file_end | Tranfers only the end of the file
196 This ordering is very important, so that you can save the transferred files to hard disk on client side with a dlt viewer plugin.
197 The advantage of using several steps to transfer files by your own is, that you are very flexible to integrate the filetransfer
200 An other difference to the automatic method is, that only a timeout will be done. There is no check of the user buffer.
202 \subsection Important Important for integration
203 You should care about blocking the main program when you intergrate filetransfer in your code.
204 Maybe it's useful to extract the filetransfer in an extra thread.
205 Another point is the filesize. The bigger the file is, the longer takes it to log the file to dlt.
207 \section Example Example dlt filetransfer
208 For an example file transfer you can use
210 Usage: dlt-example-filetransfer [options] <command>
211 Filetransfer example with DLT Package Version: 2.2.0 , Package Revision: 1666, build on May 28 2011 02:18:19
214 -f file - File to transfer (absolute path)
216 -a apid - Set application id to apid (default: FLTR)
217 -c ctid - Set context id to ctid (default: FLTR)
218 -t ms - Timeout between file packages in ms (minimum 20 ms)
219 -d - Flag to delete the file after the transfer (default: false)
220 -i - Flag to log file infos to DLT before transfer file (default: false)
224 \section Test Testing dlt filetransfer
225 When you call "sudo make install", some automatic tests will be installed. Start the test using the following command from bash:
227 dlt-test-filetransfer
229 It's important that the dlt-filetransfer example files are installed in /usr/share/dlt-filetransfer which will be done automatically by using "sudo make install".
230 \subsection testFile1Run1
231 Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using dlt_user_log_file_complete.
232 \subsection testFile1Run2
233 Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using single package transfer
234 \subsection testFile2Run1
235 Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using dlt_user_log_file_complete.
236 \subsection testFile2Run2
237 Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using single package transfer
238 \subsection testFile3Run1
239 Test the file transfer with the condition that the transferred file does not exist using dlt_user_log_file_complete.
240 \subsection testFile3Run2
241 Test the file transfer with the condition that the transferred file does not exist using single package transfer
242 \subsection testFile3Run3
243 Test which logs some information about the file.
248 \section Requirements Requirements
254 \section Licence Licence
255 Copyright 2011 - BMW AG, Christian Muck <christian.muck@bmw.de>