automotive-dlt
dlt_shm.h
Go to the documentation of this file.
1 /*
2  * @licence app begin@
3  * SPDX license identifier: MPL-2.0
4  *
5  * Copyright (C) 2011-2015, BMW AG
6  *
7  * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
8  *
9  * This Source Code Form is subject to the terms of the
10  * Mozilla Public License (MPL), v. 2.0.
11  * If a copy of the MPL was not distributed with this file,
12  * You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  * For further information see http://www.genivi.org/.
15  * @licence end@
16  */
17 
28 /*******************************************************************************
29 ** **
30 ** SRC-MODULE: dlt_shm.h **
31 ** **
32 ** TARGET : linux **
33 ** **
34 ** PROJECT : DLT **
35 ** **
36 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
37 ** **
38 ** PURPOSE : **
39 ** **
40 ** REMARKS : **
41 ** **
42 ** PLATFORM DEPENDANT [yes/no]: yes **
43 ** **
44 ** TO BE CHANGED BY USER [yes/no]: no **
45 ** **
46 *******************************************************************************/
47 
48 /*******************************************************************************
49 ** Author Identity **
50 ********************************************************************************
51 ** **
52 ** Initials Name Company **
53 ** -------- ------------------------- ---------------------------------- **
54 ** aw Alexander Wenzel BMW **
55 *******************************************************************************/
56 
57 #ifndef DLT_SHM_H
58 #define DLT_SHM_H
59 
60 #include "dlt_common.h"
61 
62 /* shared memory key */
63 /* must be the same for server and cleint */
64 #define DLT_SHM_KEY 11771
65 
66 /* default size of shared memory */
67 /* size is extended during creation to fit segment size */
68 /* client retreives real size from shm buffer */
69 #define DLT_SHM_SIZE 100000
70 
71 /* Id of the used semaphore */
72 /* used for synchronisation of write and read access of multiple clients and server */
73 /* must be the same for server and client */
74 #define DLT_SHM_SEM 22771
75 
76 #define DLT_SHM_HEAD "SHM"
77 
78 typedef struct
79 {
80  int shmid; /* Id of shared memory */
81  int semid; /* Id of semaphore */
83 } DltShm;
84 
85 typedef struct
86 {
87  char head[4];
88  unsigned char status;
89  int size;
91 
92 #define DLT_SHM_SEM_GET(id) dlt_shm_pv(id,-1)
93 #define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id,1)
94 
102 extern DltReturnValue dlt_shm_init_client(DltShm *buf,int key);
103 
112 extern DltReturnValue dlt_shm_init_server(DltShm *buf,int key,int size);
113 
125 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);
126 
136 extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size);
137 
147 extern int dlt_shm_copy(DltShm *buf,unsigned char *data, int size);
148 
156 extern int dlt_shm_remove(DltShm *buf);
157 
162 extern void dlt_shm_info(DltShm *buf);
163 
168 extern void dlt_shm_status(DltShm *buf);
169 
176 
182 extern int dlt_shm_get_total_size(DltShm *buf);
183 
189 extern int dlt_shm_get_used_size(DltShm *buf);
190 
196 extern int dlt_shm_get_message_count(DltShm *buf);
197 
203 extern int dlt_shm_reset(DltShm *buf);
204 
210 extern int dlt_shm_recover(DltShm *buf);
211 
217 extern int dlt_shm_free_server(DltShm *buf);
218 
219 #endif /* DLT_SHM_H */
DltReturnValue dlt_shm_init_client(DltShm *buf, int key)
Definition: dlt_shm.c:144
DltReturnValue
Definition: dlt_types.h:86
Definition: dlt_shm.h:78
int dlt_shm_pull(DltShm *buf, unsigned char *data, int size)
Definition: dlt_shm.c:233
int dlt_shm_get_total_size(DltShm *buf)
Definition: dlt_shm.c:193
int dlt_shm_get_message_count(DltShm *buf)
Definition: dlt_shm.c:213
static char data[kDataSize]
Definition: city-test.cc:40
int dlt_shm_free_server(DltShm *buf)
Definition: dlt_shm.c:278
DltReturnValue dlt_shm_free_client(DltShm *buf)
Definition: dlt_shm.c:303
DltBuffer buffer
Definition: dlt_shm.h:82
DltReturnValue dlt_shm_init_server(DltShm *buf, int key, int size)
Definition: dlt_shm.c:99
int dlt_shm_remove(DltShm *buf)
Definition: dlt_shm.c:263
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)
Definition: dlt_shm.c:218
int dlt_shm_recover(DltShm *buf)
int dlt_shm_reset(DltShm *buf)
void dlt_shm_info(DltShm *buf)
Definition: dlt_shm.c:183
void dlt_shm_status(DltShm *buf)
Definition: dlt_shm.c:188
unsigned char status
Definition: dlt_shm.h:88
int dlt_shm_copy(DltShm *buf, unsigned char *data, int size)
Definition: dlt_shm.c:248
int dlt_shm_get_used_size(DltShm *buf)
Definition: dlt_shm.c:198
int shmid
Definition: dlt_shm.h:80
int semid
Definition: dlt_shm.h:81