automotive-dlt
dlt_filetransfer.h File Reference
#include <limits.h>
#include <sys/stat.h>
#include "dlt.h"
#include <signal.h>
#include "errno.h"
Include dependency graph for dlt_filetransfer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE   -300
 
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE1   -301
 
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE2   -302
 
#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE3   -303
 
#define DLT_FILETRANSFER_ERROR_FILE_HEAD   -400
 
#define DLT_FILETRANSFER_ERROR_FILE_DATA   -500
 
#define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED   -501
 
#define DLT_FILETRANSFER_ERROR_FILE_END   -600
 
#define DLT_FILETRANSFER_ERROR_INFO_ABOUT   -700
 
#define DLT_FILETRANSFER_ERROR_PACKAGE_COUNT   -800
 

Functions

int dlt_user_log_file_complete (DltContext *fileContext, const char *filename, int deleteFlag, int timeout)
 Transfer the complete file as several dlt logs. More...
 
int dlt_user_log_file_packagesCount (DltContext *fileContext, const char *filename)
 This method gives information about the number of packages the file have. More...
 
int dlt_user_log_file_infoAbout (DltContext *fileContext, const char *filename)
 Logs specific file inforamtions to dlt. More...
 
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. More...
 
int dlt_user_log_file_header (DltContext *fileContext, const char *filename)
 Transfer the head of the file as a dlt logs. More...
 
int dlt_user_log_file_data (DltContext *fileContext, const char *filename, int packageToTransfer, int timeout)
 Transfer the content data of a file. More...
 
int dlt_user_log_file_end (DltContext *fileContext, const char *filename, int deleteFlag)
 Transfer the end of the file as a dlt logs. More...
 

Detailed Description

Author
Alexander Wenzel alexa.nosp@m.nder.nosp@m..aw.w.nosp@m.enze.nosp@m.l@bmw.nosp@m..de

Definition in file dlt_filetransfer.h.

Macro Definition Documentation

#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE   -300

Definition at line 35 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_complete().

#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE1   -301

Definition at line 37 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_complete().

#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE2   -302

Definition at line 39 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_complete().

#define DLT_FILETRANSFER_ERROR_FILE_COMPLETE3   -303

Definition at line 41 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_complete().

#define DLT_FILETRANSFER_ERROR_FILE_DATA   -500

Definition at line 45 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_data().

#define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED   -501

Definition at line 47 of file dlt_filetransfer.h.

#define DLT_FILETRANSFER_ERROR_FILE_END   -600

Definition at line 49 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_end().

#define DLT_FILETRANSFER_ERROR_FILE_HEAD   -400

Definition at line 43 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_header(), and dlt_user_log_file_header_alias().

#define DLT_FILETRANSFER_ERROR_INFO_ABOUT   -700

Definition at line 51 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_infoAbout().

#define DLT_FILETRANSFER_ERROR_PACKAGE_COUNT   -800

Definition at line 53 of file dlt_filetransfer.h.

Referenced by dlt_user_log_file_packagesCount().

Function Documentation

int dlt_user_log_file_complete ( DltContext fileContext,
const char *  filename,
int  deleteFlag,
int  timeout 
)

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
deleteFlagFlag if the file will be deleted after transfer. 1->delete, 0->notDelete
timeoutTimeout 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.
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
deleteFlagFlag if the file will be deleted after transfer. 1->delete, 0->notDelete
timeoutTimeout 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.
Returns
Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 317 of file dlt_filetransfer.c.

References DLT_FILETRANSFER_ERROR_FILE_COMPLETE, DLT_FILETRANSFER_ERROR_FILE_COMPLETE1, DLT_FILETRANSFER_ERROR_FILE_COMPLETE2, DLT_FILETRANSFER_ERROR_FILE_COMPLETE3, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES, dlt_user_log_file_data(), dlt_user_log_file_end(), dlt_user_log_file_errorMessage(), dlt_user_log_file_header(), and isFile().

Referenced by main(), testFile1Run1(), testFile2Run1(), and testFile3Run1().

int dlt_user_log_file_data ( DltContext fileContext,
const char *  filename,
int  packageToTransfer,
int  timeout 
)

Transfer the content data of a file.

See the Mainpages.c for more informations.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
packageToTransferPackage number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
timeoutTimeout 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.
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

See the Mainpages.c for more informations.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
packageToTransferPackage number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
timeoutTimeout 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.
Returns
Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 496 of file dlt_filetransfer.c.

References buffer, BUFFER_SIZE, checkUserBufferForFreeSpace(), DLT_FILETRANSFER_ERROR_FILE_DATA, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES, DLT_INT, DLT_LOG, DLT_LOG_ERROR, DLT_LOG_INFO, DLT_RAW, DLT_STRING, DLT_UINT, dlt_user_log_file_errorMessage(), dlt_user_log_file_packagesCount(), doTimeout(), getFileSerialNumber(), isFile(), and NULL.

Referenced by dlt_user_log_file_complete(), send_dumped_file(), testFile1Run2(), testFile2Run2(), and testFile3Run2().

int dlt_user_log_file_end ( DltContext fileContext,
const char *  filename,
int  deleteFlag 
)

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
deleteFlagFlag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
deleteFlagFlag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
Returns
Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 621 of file dlt_filetransfer.c.

References DLT_FILETRANSFER_ERROR_FILE_END, DLT_LOG, DLT_LOG_ERROR, DLT_LOG_INFO, DLT_STRING, DLT_UINT, dlt_user_log_file_errorMessage(), doRemoveFile(), getFileSerialNumber(), and isFile().

Referenced by dlt_user_log_file_complete(), send_dumped_file(), testFile1Run2(), testFile2Run2(), and testFile3Run2().

int dlt_user_log_file_header ( 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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
Returns
Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 447 of file dlt_filetransfer.c.

References BUFFER_SIZE, DLT_FILETRANSFER_ERROR_FILE_HEAD, DLT_LOG, DLT_LOG_ERROR, DLT_LOG_INFO, DLT_STRING, DLT_UINT, dlt_user_log_file_errorMessage(), dlt_user_log_file_packagesCount(), getFileCreationDate2(), getFileSerialNumber(), getFilesize(), and isFile().

Referenced by dlt_user_log_file_complete(), testFile1Run2(), testFile2Run2(), and testFile3Run2().

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
aliasAlias for the file. An alternative name to show in the receiving end
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
aliasAlias for the file. An alternative name to show in the receiving end
Returns
Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 398 of file dlt_filetransfer.c.

References BUFFER_SIZE, DLT_FILETRANSFER_ERROR_FILE_HEAD, DLT_LOG, DLT_LOG_ERROR, DLT_LOG_INFO, DLT_STRING, DLT_UINT, dlt_user_log_file_errorMessage(), dlt_user_log_file_packagesCount(), getFileCreationDate2(), getFileSerialNumber(), getFilesize(), and isFile().

Referenced by send_dumped_file().

int dlt_user_log_file_infoAbout ( 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.

Parameters
fileContextSpecific context
filenameAbsolute file path
Returns
Returns 0 if everything was okey.If there was a failure value < 0 will be returned.

The filename, file size, file serial number and the number of packages will be logged to dlt.

Parameters
fileContextSpecific context
filenameAbsolute file path
Returns
Returns 0 if everything was okey.If there was a failure a value < 0 will be returned.

Definition at line 270 of file dlt_filetransfer.c.

References DLT_FILETRANSFER_ERROR_INFO_ABOUT, DLT_LOG, DLT_LOG_ERROR, DLT_LOG_INFO, DLT_STRING, DLT_UINT, dlt_user_log_file_errorMessage(), dlt_user_log_file_packagesCount(), getFileCreationDate2(), getFileSerialNumber(), getFilesize(), and isFile().

Referenced by main(), and testFile3Run3().

int dlt_user_log_file_packagesCount ( DltContext fileContext,
const char *  filename 
)

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
Returns
Returns 0 if everything was okey. If there was a failure value < 0 will be returned.

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.

Parameters
fileContextSpecific context to log the file to dlt
filenameAbsolute file path
Returns
Returns the number of packages if everything was okey. If there was a failure a value < 0 will be returned.

Definition at line 352 of file dlt_filetransfer.c.

References BUFFER_SIZE, DLT_FILETRANSFER_ERROR_PACKAGE_COUNT, DLT_INT, DLT_LOG, DLT_LOG_ERROR, DLT_STRING, getFilesize(), and isFile().

Referenced by dlt_user_log_file_data(), dlt_user_log_file_errorMessage(), dlt_user_log_file_header(), dlt_user_log_file_header_alias(), dlt_user_log_file_infoAbout(), send_dumped_file(), testFile1Run2(), testFile2Run2(), and testFile3Run2().