diff options
author | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2011-09-28 18:24:37 +0200 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2011-09-28 18:24:37 +0200 |
commit | 966bffa7397f0479640f2232c6a2d1667026952e (patch) | |
tree | 1593c54018d6ba6e50faa641000379be98b8d9bc /include | |
parent | 76b3293857f63563ae0a98a834591cd9d26353d9 (diff) | |
parent | 106dbe47ccd610a6cad2980838498ba8497a249f (diff) | |
download | DLT-daemon-966bffa7397f0479640f2232c6a2d1667026952e.tar.gz |
Merge branch 'master' of QMUC300924:/home/git/DLT-daemon
Diffstat (limited to 'include')
-rwxr-xr-x | include/dlt/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | include/dlt/dlt_common.h | 70 | ||||
-rw-r--r-- | include/dlt/dlt_shm.h | 186 | ||||
-rwxr-xr-x | include/dlt/dlt_user.h | 3 | ||||
-rwxr-xr-x | include/dlt/dlt_version.h | 2 |
5 files changed, 190 insertions, 73 deletions
diff --git a/include/dlt/CMakeLists.txt b/include/dlt/CMakeLists.txt index 6ddcfad..95b9929 100755 --- a/include/dlt/CMakeLists.txt +++ b/include/dlt/CMakeLists.txt @@ -35,6 +35,6 @@ # @licence end@ ######## -install(FILES dlt.h dlt_user.h dlt_user_macros.h dlt_client.h dlt_protocol.h dlt_common.h dlt_types.h dlt_version.h +install(FILES dlt.h dlt_user.h dlt_user_macros.h dlt_client.h dlt_protocol.h dlt_common.h dlt_types.h dlt_version.h dlt_shm.h DESTINATION include/dlt COMPONENT devel) diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 67371be..3a1c9d2 100755 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -932,76 +932,6 @@ extern "C" */ int dlt_check_storageheader(DltStorageHeader *storageheader); - /** - * Initialize ringbuffer of with a maximum size of size - * @param dltbuf Pointer to ringbuffer structure - * @param size Maximum size of buffer in bytes - * @return negative value if there was an error - */ - int dlt_ringbuffer_init(DltRingBuffer *dltbuf, uint32_t size); - - /** - * Release and free memory used by ringbuffer - * @param dltbuf Pointer to ringbuffer structure - * @return negative value if there was an error - */ - int dlt_ringbuffer_free(DltRingBuffer *dltbuf); - - /** - * Write one entry to ringbuffer - * @param dltbuf Pointer to ringbuffer structure - * @param data Pointer to data to be written to ringbuffer - * @param size Size of data in bytes to be written to ringbuffer - * @return negative value if there was an error - */ - int dlt_ringbuffer_put(DltRingBuffer *dltbuf, void *data, uint32_t size); - - /** - * Write one entry given as 3 chunks to ringbuffer - * @param dltbuf Pointer to ringbuffer structure - * @param data1 Pointer to data1 to be written to ringbuffer - * @param size1 Size of data1 in bytes to be written to ringbuffer - * @param data2 Pointer to data2 to be written to ringbuffer - * @param size2 Size of data2 in bytes to be written to ringbuffer - * @param data3 Pointer to data3 to be written to ringbuffer - * @param size3 Size of data3 in bytes to be written to ringbuffer - * @return negative value if there was an error - */ - int dlt_ringbuffer_put3(DltRingBuffer *dltbuf, void *data1, uint32_t size1, void *data2, uint32_t size2, void *data3, uint32_t size3); - - /** - * Read one entry from ringbuffer - * @param dltbuf Pointer to ringbuffer structure - * @param data Pointer to data read from ringbuffer - * @param size Size of read data in bytes from ringbuffer - * @return negative value if there was an error - */ - int dlt_ringbuffer_get(DltRingBuffer *dltbuf, void *data, size_t *size); - - /** - * Helper function: Skip one readable entry in ringbuffer - * @param dltbuf Pointer to ringbuffer structure - * @return negative value if there was an error - */ - int dlt_ringbuffer_get_skip(DltRingBuffer *dltbuf); - - /** - * Helper function: Get free space in bytes for writting between write and read position - * @param dltbuf Pointer to ringbuffer structure - * @param freespace Free Space in bytes for writting is returned - * @return negative value if there was an error - */ - int dlt_ringbuffer_freespacewrite(DltRingBuffer *dltbuf, uint32_t *freespace); - - /** - * Helper function: Check free space and if necessary discard entries, so that at least - * reqspace bytes are available for writting - * @param dltbuf Pointer to ringbuffer structure - * @param reqspace Requested space for writting in bytes - * @return negative value if there was an error - */ - int dlt_ringbuffer_checkandfreespace(DltRingBuffer *dltbuf, uint32_t reqspace); - #if !defined (__WIN32__) /** diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h new file mode 100644 index 0000000..fc37117 --- /dev/null +++ b/include/dlt/dlt_shm.h @@ -0,0 +1,186 @@ +/* +* Dlt- Diagnostic Log and Trace user library +* @licence app begin@ + * + * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de> + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License, version 2.1, for more details. + * + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along + * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>. + * + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may + * also be applicable to programs even in cases in which the program is not a library in the technical sense. + * + * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may + * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to + * license your linked modules under the GNU Lesser General Public License, version 2.1, you + * may use the program under the following exception. + * + * As a special exception, the copyright holders of DLT give you permission to combine DLT + * with software programs or libraries that are released under any license unless such a combination is not + * permitted by the license of such a software program or library. You may copy and distribute such a + * system following the terms of the GNU Lesser General Public License, version 2.1, including this + * special exception, for DLT and the licenses of the other code concerned. + * + * Note that people who make modified versions of DLT are not obligated to grant this special exception + * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, + * version 2.1, gives permission to release a modified version without this exception; this exception + * also makes it possible to release a modified version which carries forward this exception. + * + * @licence end@ +*/ + + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_shm.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** aw Alexander Wenzel BMW ** +*******************************************************************************/ + +#ifndef DLT_SHM_H +#define DLT_SHM_H + +/* shared memory key */ +/* must be the same for server and cleint */ +#define DLT_SHM_KEY 11771 + +/* default size of shared memory */ +/* size is extended during creation to fit segment size */ +/* client retreives real size from shm buffer */ +#define DLT_SHM_SIZE 100000 + +/* Id of the used semaphore */ +/* used for synchronisation of write and read access of multiple clients and server */ +/* must be the same for server and client */ +#define DLT_SHM_SEM 22771 + +typedef struct +{ + int shmid; /* Id of shared memory */ + int semid; /* Id of semaphore */ + char* shm; /* pointer to beginning of shared memory */ + int size; /* size of data area in shared memory */ + char* mem; /* pointer to data area in shared memory */ +} DltShm; + +#define DLT_SHM_SEM_GET(id) dlt_shm_pv(id,-1) +#define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id,1) + +/** + * Initialise the shared memory on the client side. + * This function must be called before using further shm functions. + * @param buf pointer to shm structure + * @param key the identifier of the shm, must be the same for server and client + * @return negative value if there was an error + */ +extern int dlt_shm_init_client(DltShm *buf,int key); + +/** + * Initialise the shared memory on the server side. + * This function must be called before using further shm functions. + * @param buf pointer to shm structure + * @param key the identifier of the shm, must be the same for server and client + * @param size the requested size of the shm + * @return negative value if there was an error + */ +extern int dlt_shm_init_server(DltShm *buf,int key,int size); + +/** + * Push data from client onto the shm. + * @param buf pointer to shm structure + * @param data1 pointer to first data block to be written, null if not used + * @param size1 size in bytes of first data block to be written, 0 if not used + * @param data2 pointer to second data block to be written, null if not used + * @param size2 size in bytes of second data block to be written, 0 if not used + * @param data3 pointer to third data block to be written, null if not used + * @param size3 size in bytes of third data block to be written, 0 if not used + * @return negative value if there was an error + */ +extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3); + +/** + * Pull data from shm. + * This function should be called from client. + * Data is deleted from shm after this call. + * @param buf pointer to shm structure + * @param data pointer to buffer where data is to be written + * @param size maximum size to be written into buffer + * @return negative value if there was an error + */ +extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size); + +/** + * Copy message from shm. + * This function should be called from server. + * Data is not deleted from shm after this call. + * @param buf pointer to shm structure + * @param data pointer to buffer where data is to be written + * @param size maximum size to be written into buffer + * @return negative value if there was an error + */ +extern int dlt_shm_copy(DltShm *buf,unsigned char *data, int size); + +/** + * Delete message from shm. + * This function should be called from server. + * This function should be called after each succesful copy. + * @param buf pointer to shm structure + * @return negative value if there was an error + */ +extern int dlt_shm_remove(DltShm *buf); + +/** + * Print information about shm. + * @param buf pointer to shm structure + */ +extern void dlt_shm_info(DltShm *buf); + +/** + * Print status about shm. + * @param buf pointer to shm structure + */ +extern void dlt_shm_status(DltShm *buf); + +/** + * Deinitialise the shared memory on the client side. + * @param buf pointer to shm structure + * @return negative value if there was an error + */ +extern int dlt_shm_free_client(DltShm *buf); + +/** + * Deinitialise the shared memory on the server side. + * @param buf pointer to shm structure + * @return negative value if there was an error + */ +extern int dlt_shm_free_server(DltShm *buf); + +#endif /* DLT_SHM_H */ diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index 263a5f2..1ea46cc 100755 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -91,6 +91,7 @@ #include "dlt_types.h" #include "dlt_common.h" #include "dlt_user_macros.h" +#include "dlt_shm.h" #if !defined (__WIN32__) #include <semaphore.h> @@ -225,7 +226,7 @@ typedef struct int8_t enable_local_print; /**< Local printing of log messages: 1 enabled, 0 disabled */ int8_t local_print_mode; /**< Local print mode, controlled by environment variable */ - DltRingBuffer rbuf; /**< Ring-buffer for buffering messages during startup and missing connection */ + DltShm dlt_shm; } DltUser; /************************************************************************************************** diff --git a/include/dlt/dlt_version.h b/include/dlt/dlt_version.h index 1ea8756..30152fd 100755 --- a/include/dlt/dlt_version.h +++ b/include/dlt/dlt_version.h @@ -7,6 +7,6 @@ #define PACKAGE_MAJOR_VERSION "2" #define PACKAGE_MINOR_VERSION "3" #define PACKAGE_PATCH_LEVEL "0" -#define PACKAGE_REVISION "v2.3.0" +#define PACKAGE_REVISION "v2.3.0-20-g9e988e6" #endif |