2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file ns_msg_queue.h
19 * @brief \~english TestFramework provides interface for implementing functional test classes.
22 /** @addtogroup BaseSystem
25 /** @addtogroup native_service
29 /** @addtogroup framework_unified
30 * @ingroup native_service
33 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_
34 #define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_
36 #include <native_service/frameworkunified_types.h>
43 /// \brief Enum that defines the value Q Types
50 // PASA CCR IPC Framework API
52 ////////////////////////////////////////////////////////////////////////////////////////////
54 /// The opens a handle to a Receiver message queue.
57 /// PCSTR - name of the message queue you want to receiver messages on
60 /// handle - to a recevier's message queue
61 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
62 /// INVALID_HANDLE - or an error occurred while opening a queue
63 ////////////////////////////////////////////////////////////////////////////////////////////
64 HANDLE OpenReceiver(PCSTR name);
66 ////////////////////////////////////////////////////////////////////////////////////////////
67 /// OpenReceiverNotBlocked
68 /// The opens a handle to a Receiver message queue. Operations on this queue
69 /// are non-blocking if queue is empty or full.
72 /// PCSTR - name of the message queue you want to receiver messages on
75 /// handle - to a recevier's message queue
76 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
77 /// INVALID_HANDLE - or an error occurred while opening a queue
78 ////////////////////////////////////////////////////////////////////////////////////////////
79 HANDLE OpenReceiverNotBlocked(PCSTR name);
81 ////////////////////////////////////////////////////////////////////////////////////////////
83 /// The opens a handle to a response Receiver message queue.
86 /// PCSTR - name of the message queue you want to receiver messages on
89 /// handle - to a recevier's message queue
90 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
91 /// INVALID_HANDLE - or an error occurred while opening a queue
92 ////////////////////////////////////////////////////////////////////////////////////////////
93 HANDLE openSyncReceiver(PCSTR name);
95 ////////////////////////////////////////////////////////////////////////////////////////////
97 /// The opens a handle for sending messages to another message queue.
100 /// PCSTR - name of the message queue you want to send messages too
103 /// handle - senders message queue handle
104 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
105 /// INVALID_HANDLE - or an error occurred while opening a queue
106 ////////////////////////////////////////////////////////////////////////////////////////////
107 HANDLE OpenSender(PCSTR name);
109 ////////////////////////////////////////////////////////////////////////////////////////////
111 /// The opens a handle for sending response to another message queue.
114 /// PCSTR - name of the message queue you want to send messages too
117 /// handle - senders message queue handle
118 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
119 /// INVALID_HANDLE - or an error occurred while opening a queue
120 ////////////////////////////////////////////////////////////////////////////////////////////
121 HANDLE openSyncSender(PCSTR name);
123 ////////////////////////////////////////////////////////////////////////////////////////////
125 /// The opens a handle for sending response to another message queue.
128 /// PCSTR - name of the message queue you want to send messages too
131 /// handle - senders message queue handle
132 /// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
133 /// INVALID_HANDLE - or an error occurred while opening a queue
134 ////////////////////////////////////////////////////////////////////////////////////////////
135 HANDLE openSenderZc(PCSTR name);
137 /////////////////////////////////////////
139 HANDLE OpenSenderChild(PCSTR name, pthread_t threadid);
140 /////////////////////////////////////////
142 /////////////////////////////////////////
143 EFrameworkunifiedStatus JoinChild(HANDLE hChildApp);
144 /////////////////////////////////////////
146 /////////////////////////////////////////
147 EFrameworkunifiedStatus GetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
148 /////////////////////////////////////////
151 ////////////////////////////////////////////////////////////////////////////////////////////
153 /// The function sends a message to a queue.
155 /// \param [in] hMessage
156 /// Handle - handle to the sendMessage, OpenSender
157 /// \param [in] length
158 /// UI_32 - length of the data to be sent
160 /// const void* - pointer to the data that needs to be transmitted
162 /// \return EFrameworkunifiedaStatus
163 /// status - status of the message(error)
164 ////////////////////////////////////////////////////////////////////////////////////////////
165 EFrameworkunifiedStatus SendMessage(HANDLE hMessage, UI_32 length, PVOID data);
167 ////////////////////////////////////////////////////////////////////////////////////////////
168 /// SendMessageWithPriority
169 /// The function sends a message to a queue.
171 /// \param [in] hMessage
172 /// Handle - handle to the sendMessage, OpenSender
173 /// \param [in] length
174 /// UI_32 - length of the data to be sent
176 /// const void* - pointer to the data that needs to be transmitted
177 /// \param [in] priority
178 /// EFrameworkunifiedMessagePriorties - priority at which the message should be sent at!
180 /// \return EFrameworkunifiedaStatus
181 /// status - status of the message(error)
182 ////////////////////////////////////////////////////////////////////////////////////////////
183 EFrameworkunifiedStatus SendMessageWithPriority(HANDLE hMessage, UI_32 length, PVOID data, EFrameworkunifiedMessagePriorties priority);
185 ////////////////////////////////////////////////////////////////////////////////////////////
187 /// The function blocks on a message queue waiting for data to be received.
189 /// \param [in] hMessage
190 /// HANDLE - handle to the recvMessage, OpenReceiver
191 /// \param [in] length
192 /// UI_32 - length of the data buffer provided
194 /// void* - pointer to the data to be received
197 /// length read - indicates the number of bytes that were read from the queue (eFrameworkunifiedStatusErrOther) error
198 ////////////////////////////////////////////////////////////////////////////////////////////
199 SI_32 ReceiveMessage(HANDLE hMessage, UI_32 length, PVOID data);
201 ////////////////////////////////////////////////////////////////////////////////////////////
203 /// The closes a connection to a Receiver message queue.
205 /// \param [in] hMessage
206 /// HANDLE - handle to the recvMessage that will be closed
208 /// \return EFrameworkunifiedaStatus
209 /// status - indicates if the close was successfully (eFrameworkunifiedStatusOK) or not (anything else)
210 ////////////////////////////////////////////////////////////////////////////////////////////
211 EFrameworkunifiedStatus CloseReceiver(HANDLE handle);
213 ////////////////////////////////////////////////////////////////////////////////////////////
215 /// The closes a connection to a Receiver message queue.
217 /// \param [in] hMessage
218 /// HANDLE - handle to the recvMessage that will be closed
220 /// \return EFrameworkunifiedaStatus
221 /// status - indicates if the close was successfully (eFrameworkunifiedStatusOK) or not (anything else)
222 ////////////////////////////////////////////////////////////////////////////////////////////
223 EFrameworkunifiedStatus CloseSender(HANDLE handle);
226 ////////////////////////////////////////////////////////////////////////////////////////////
228 /// Flush all data on HANDLE's Receiver message queue.
230 /// \param [in] hMessage
231 /// HANDLE - handle to the recvMessage queue that will be flushed
234 ////////////////////////////////////////////////////////////////////////////////////////////
235 void Flush(HANDLE hMessage);
237 ////////////////////////////////////////////////////////////////////////////////////////////
239 /// Get the handle's queue type.
241 /// \param [in] hMessage
242 /// HANDLE - handle to the Message queue
245 /// EQType - queue type of handle
246 ////////////////////////////////////////////////////////////////////////////////////////////
247 EQType GetQueueType(HANDLE hMessage);
249 ////////////////////////////////////////////////////////////////////////////////////////////
250 // Function : TranslateError
251 // Translates global error variables into FW EFrameworkunifiedStatus
253 /// \param [in] error
254 /// int - error variable
256 /// \return EFrameworkunifiedStatus
257 /// EFrameworkunifiedStatus - frameworkunified error type
258 ////////////////////////////////////////////////////////////////////////////////////////////
259 EFrameworkunifiedStatus TranslateError(int error);
261 ////////////////////////////////////////////////////////////////////////////////////////////
263 /// This gets the name of the message queue
265 /// \param [in] hMessage
266 /// HANDLE - handle of the message queue
267 /// (handle created with McOpenReceiver or McOpenSender)
270 /// name - name of the message queue if handle is valid else NULL
271 ////////////////////////////////////////////////////////////////////////////////////////////
272 PCSTR GetQueueName(HANDLE hMessage);
274 ////////////////////////////////////////////////////////////////////////////////////////////
276 /// This gets the fd of the message queue
278 /// \param [in] hMessage
279 /// HANDLE - handle of the message queue
280 /// (handle created with McOpenReceiver or McOpenSender)
283 /// fd - fd of the message queue if handle is valid else -1
284 ////////////////////////////////////////////////////////////////////////////////////////////
285 int GetQueueFD(HANDLE hMessage);
291 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_