automotive-dlt
dlt_shm.h File Reference
#include "dlt_common.h"
Include dependency graph for dlt_shm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DltShm
 
struct  DltShmBlockHead
 

Macros

#define DLT_SHM_KEY   11771
 
#define DLT_SHM_SIZE   100000
 
#define DLT_SHM_SEM   22771
 
#define DLT_SHM_HEAD   "SHM"
 
#define DLT_SHM_SEM_GET(id)   dlt_shm_pv(id,-1)
 
#define DLT_SHM_SEM_FREE(id)   dlt_shm_pv(id,1)
 

Functions

DltReturnValue dlt_shm_init_client (DltShm *buf, int key)
 
DltReturnValue dlt_shm_init_server (DltShm *buf, int key, int size)
 
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)
 
int dlt_shm_pull (DltShm *buf, unsigned char *data, int size)
 
int dlt_shm_copy (DltShm *buf, unsigned char *data, int size)
 
int dlt_shm_remove (DltShm *buf)
 
void dlt_shm_info (DltShm *buf)
 
void dlt_shm_status (DltShm *buf)
 
DltReturnValue dlt_shm_free_client (DltShm *buf)
 
int dlt_shm_get_total_size (DltShm *buf)
 
int dlt_shm_get_used_size (DltShm *buf)
 
int dlt_shm_get_message_count (DltShm *buf)
 
int dlt_shm_reset (DltShm *buf)
 
int dlt_shm_recover (DltShm *buf)
 
int dlt_shm_free_server (DltShm *buf)
 

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_shm.h.

Macro Definition Documentation

#define DLT_SHM_HEAD   "SHM"

Definition at line 76 of file dlt_shm.h.

#define DLT_SHM_KEY   11771

Definition at line 64 of file dlt_shm.h.

Referenced by dlt_daemon_local_init_p2(), dlt_init(), and dlt_user_log_reattach_to_daemon().

#define DLT_SHM_SEM   22771

Definition at line 74 of file dlt_shm.h.

Referenced by dlt_shm_init_client(), and dlt_shm_init_server().

#define DLT_SHM_SEM_FREE (   id)    dlt_shm_pv(id,1)
#define DLT_SHM_SEM_GET (   id)    dlt_shm_pv(id,-1)
#define DLT_SHM_SIZE   100000

Definition at line 69 of file dlt_shm.h.

Referenced by option_file_parser().

Function Documentation

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

Parameters
bufpointer to shm structure
datapointer to buffer where data is to be written
sizemaximum size to be written into buffer
Returns
negative value if there was an error

Definition at line 248 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_copy(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.

Referenced by dlt_daemon_process_user_message_log().

DltReturnValue dlt_shm_free_client ( DltShm buf)

Deinitialise the shared memory on the client side.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

Definition at line 303 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_free_static(), dlt_log(), DLT_RETURN_ERROR, DltShm::semid, DltBuffer::shm, and DltShm::shmid.

Referenced by dlt_free(), and dlt_user_log_send_log().

int dlt_shm_free_server ( DltShm buf)

Deinitialise the shared memory on the server side.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

Definition at line 278 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_free_static(), dlt_log(), DLT_RETURN_ERROR, NULL, DltShm::semid, DltBuffer::shm, and DltShm::shmid.

Referenced by dlt_daemon_local_cleanup().

int dlt_shm_get_message_count ( DltShm buf)

Returns the number of messages in the shm.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

Definition at line 213 of file dlt_shm.c.

References DltShm::buffer, and dlt_buffer_get_message_count().

int dlt_shm_get_total_size ( DltShm buf)

Returns the total size of the shm.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

Definition at line 193 of file dlt_shm.c.

References DltShm::buffer, and dlt_buffer_get_total_size().

Referenced by dlt_user_check_buffer().

int dlt_shm_get_used_size ( DltShm buf)

Returns the used size in the shm.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

Definition at line 198 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_get_used_size(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.

Referenced by dlt_user_check_buffer().

void dlt_shm_info ( DltShm buf)

Print information about shm.

Parameters
bufpointer to shm structure

Definition at line 183 of file dlt_shm.c.

References DltShm::buffer, and dlt_buffer_info().

DltReturnValue dlt_shm_init_client ( DltShm buf,
int  key 
)

Initialise the shared memory on the client side. This function must be called before using further shm functions.

Parameters
bufpointer to shm structure
keythe identifier of the shm, must be the same for server and client
Returns
negative value if there was an error

Definition at line 144 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_init_static_client(), dlt_log(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SHM_SEM, NULL, DltShm::semid, and DltShm::shmid.

Referenced by dlt_init(), and dlt_user_log_reattach_to_daemon().

DltReturnValue dlt_shm_init_server ( DltShm buf,
int  key,
int  size 
)

Initialise the shared memory on the server side. This function must be called before using further shm functions.

Parameters
bufpointer to shm structure
keythe identifier of the shm, must be the same for server and client
sizethe requested size of the shm
Returns
negative value if there was an error

Definition at line 99 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_init_static_server(), dlt_log(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SHM_SEM, NULL, DltShm::semid, and DltShm::shmid.

Referenced by dlt_daemon_local_init_p2().

int dlt_shm_pull ( DltShm buf,
unsigned char *  data,
int  size 
)

Pull data from shm. This function should be called from client. Data is deleted from shm after this call.

Parameters
bufpointer to shm structure
datapointer to buffer where data is to be written
sizemaximum size to be written into buffer
Returns
negative value if there was an error

Definition at line 233 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_pull(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.

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 
)

Push data from client onto the shm.

Parameters
bufpointer to shm structure
data1pointer to first data block to be written, null if not used
size1size in bytes of first data block to be written, 0 if not used
data2pointer to second data block to be written, null if not used
size2size in bytes of second data block to be written, 0 if not used
data3pointer to third data block to be written, null if not used
size3size in bytes of third data block to be written, 0 if not used
Returns
negative value if there was an error

Definition at line 218 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_push3(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.

Referenced by dlt_user_log_resend_buffer(), and dlt_user_log_send_log().

int dlt_shm_recover ( DltShm buf)

Recover to find next valid message.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.
int dlt_shm_remove ( DltShm buf)

Delete message from shm. This function should be called from server. This function should be called after each succesful copy.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

Definition at line 263 of file dlt_shm.c.

References DltShm::buffer, dlt_buffer_remove(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.

Referenced by dlt_daemon_process_user_message_log().

int dlt_shm_reset ( DltShm buf)

Reset pointers and counters when shm corrupted.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.
void dlt_shm_status ( DltShm buf)

Print status about shm.

Parameters
bufpointer to shm structure

Definition at line 188 of file dlt_shm.c.

References DltShm::buffer, and dlt_buffer_status().