TizenRT Public API  v2.0 M2
messaging.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2019 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
28 #ifndef __MESSAGING_H__
29 #define __MESSAGING_H__
30 
36 #define MSG_READ_YET 0
37 #define MSG_READ_ALL 1
38 
44  MSG_REPLY_NO_REQUIRED = 0,
45  MSG_REPLY_REQUIRED = 1,
46  MSG_TYPE_MAX
47 };
48 typedef enum msg_reply_type_e msg_reply_type_t;
49 
54  char *msg;
55  int msglen;
56  int priority;
57 };
58 typedef struct msg_send_data_s msg_send_data_t;
59 
64  char *buf;
65  int buflen;
66  pid_t sender_pid;
67 };
68 typedef struct msg_recv_buf_s msg_recv_buf_t;
69 
73 typedef void (*msg_callback_t)(msg_reply_type_t msg_type, msg_recv_buf_t *recv_data, void *cb_data);
74 
79  msg_callback_t cb_func;
80  void *cb_data;
81 };
82 typedef struct msg_callback_info_s msg_callback_info_t;
83 
100 int messaging_send_sync(const char *port_name, msg_send_data_t *send_data, msg_recv_buf_t *reply_buf);
120 int messaging_send_async(const char *port_name, msg_send_data_t *send_data, msg_recv_buf_t *reply_buf, msg_callback_info_t *cb_info);
137 int messaging_send(const char *port_name, msg_send_data_t *send_data);
151 int messaging_reply(const char *port_name, pid_t sender_pid, msg_send_data_t *reply_data);
152 
165 int messaging_multicast(const char *port_name, msg_send_data_t *send_data);
166 
178 int messaging_recv_block(const char *port_name, msg_recv_buf_t *recv_buf);
193 int messaging_recv_nonblock(const char *port_name, msg_recv_buf_t *recv_buf, msg_callback_info_t *cb_info);
204 int messaging_cleanup(const char *port_name);
205 
206 #ifdef __cplusplus
207 }
208 #endif /* __cplusplus */
209 
210 #endif
211 
int messaging_send_sync(const char *port_name, msg_send_data_t *send_data, msg_recv_buf_t *reply_buf)
Send(unicast) message with sync mode.
msg_reply_type_e
The type of sending message.
Definition: messaging.h:43
The structure of parameters which used for sending.
Definition: messaging.h:53
int messaging_recv_block(const char *port_name, msg_recv_buf_t *recv_buf)
Wait to receive unicast message from specified message port.
The structure of parameters which has callback information.
Definition: messaging.h:78
void(* msg_callback_t)(msg_reply_type_t msg_type, msg_recv_buf_t *recv_data, void *cb_data)
Called when a message is received.
Definition: messaging.h:73
int messaging_send_async(const char *port_name, msg_send_data_t *send_data, msg_recv_buf_t *reply_buf, msg_callback_info_t *cb_info)
Send(unicast) message with async mode.
The structure of parameters which used for receiving.
Definition: messaging.h:63
int messaging_cleanup(const char *port_name)
Remove the messaging port information if this message port is not used anymore.
int messaging_send(const char *port_name, msg_send_data_t *send_data)
Send(unicast) message with noreply mode.
int messaging_multicast(const char *port_name, msg_send_data_t *send_data)
Send(multicast) message.
int messaging_recv_nonblock(const char *port_name, msg_recv_buf_t *recv_buf, msg_callback_info_t *cb_info)
Set the callback for receiving messages.
int messaging_reply(const char *port_name, pid_t sender_pid, msg_send_data_t *reply_data)
Reply(unicast) message to specified message port.