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.
22 /*---------------------------------------------------------------------------------*
24 *---------------------------------------------------------------------------------*/
25 #include <native_service/frameworkunified_types.h>
26 #include <vehicle_service/positioning_base_library.h>
27 #include <native_service/ns_message_center_if.h>
28 #include "_pbEvent_Internal.h"
29 #include "_pbInternalProc.h"
31 #include <native_service/frameworkunified_framework_if.h>
32 #include "WPF_STD_private.h"
35 /*---------------------------------------------------------------------------------*
37 *---------------------------------------------------------------------------------*/
38 #define MSG_MAX_NUM_CTRL_MSGQUE (32) /* Maximum number of message queues */
39 #define MSG_MAX_NUM_CTRL_THREAD (16) /* Maximum number of threads/process */
41 #define FULL_MSG_NUM_CTRL_MSGQUE (MSG_MAX_NUM_CTRL_MSGQUE - 4) /* Message control table threshold (no free) */
42 #define WARN_MSG_NUM_CTRL_MSGQUE (MSG_MAX_NUM_CTRL_MSGQUE - 10) /* Message control table threshold (warning) */
44 /*---------------------------------------------------------------------------------*
46 *---------------------------------------------------------------------------------*/
48 @brief Control table for message queues
51 PNO pno; /**< Process No. */
52 char name[MAX_QUEUE_NAME_SIZE]; /**< Message Que Name */
53 HANDLE h_positioningbaselibrary_sender[MSG_MAX_NUM_CTRL_THREAD]; /**< handle to the Sender */
54 HANDLE h_sender; /**< handle to the Sender */
55 HANDLE h_receiver; /**< handle to the Receiver */
56 HANDLE h_zc_sender; /**< handle to the ZcSender */
57 uint8_t msg_rcv_buf[MAX_QUEUE_MSG_SIZE]; /**< Message buffer */
58 } MSG_CTRL_DETAIL_INFO;
61 @brief Control table for message queues
64 MSG_CTRL_DETAIL_INFO info[MSG_MAX_NUM_CTRL_MSGQUE]; /**< message infomation */
65 uint32_t use_cnt; /**< Use Counter */
66 uint32_t rsv_cnt; /**< Reserve Counter */
69 /*---------------------------------------------------------------------------------*
71 *---------------------------------------------------------------------------------*/
74 Note: Access to this instance shall be made through the operation module.
76 static MSG_CTRL_INFO g_msg_ctrl_tbl; // NOLINT(readability/nolint) global Class instance
78 /** Message-control-table-locking Mutex handles */
79 static HANDLE g_h_mtx;
81 /*---------------------------------------------------------------------------------*
82 * Local Function Prototype *
83 *---------------------------------------------------------------------------------*/
84 /* Message Control Table Operation Functions */
85 static void MsgSetPnoOfCtrlTbl(u_int32 idx, PNO pno); /* PNO setting */
86 static PNO MsgGetPnoOfCtrlTbl(u_int32 idx); /* PNO acquisition */
87 static void MsgSetNameOfCtrlTbl(u_int32 idx, LPCTSTR name); /* Message queue name setting */
88 static char* MsgGetNameOfCtrlTbl(u_int32 idx); /* Get Message Queue Name */
89 static void MsgSetReceiverHandleOfCtrlTbl(u_int32 idx, HANDLE handle); /* Message queue handle setting */
90 static HANDLE MsgGetReceiverHandleOfCtrlTbl(u_int32 idx); /* Get message queue handle */
91 static void MsgSetSenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle); /* Message send handle setting */
92 static HANDLE MsgGetSenderHandleOfCtrlTbl(u_int32 idx); /* Get message send handle */
93 /* Message send handle setting*/
94 static void MsgSetPositioningbaselibrarySenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle, uint32_t offset);
95 static HANDLE MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(u_int32 idx, uint32_t offset); /* Get message send handle */
96 static void MsgSetZcSenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle); /* Message send handle setting */
97 static HANDLE MsgGetZcSenderHandleOfCtrlTbl(u_int32 idx); /* Get message send handle */
98 static uint8_t* MsgGetMsgRcvBufOfCtrlTbl(uint32_t idx); /* Get message receive buffer */
99 static u_int32 MsgSearchEmptyOfCtrlTbl(void); /* Retrieval of free space in control table */
100 static u_int32 MsgSearchPnoOfCtrlTbl(PNO pno); /* Retrieval of control table PNO */
101 static u_int32 MsgSearchNameOfCtrlTbl(LPCTSTR name); /* Retrieve control table queue name */
102 static void MsgIncUseCntOfCtrlTbl(void); /* Control table usage counter increment */
103 static void MsgDecUseCntOfCtrlTbl(void); /* Control table usage counter increment */
104 static void MsgIncRsvCntOfCtrlTbl(void); /* Control table reservation counter increment */
105 static void MsgDecRsvCntOfCtrlTbl(void); /* Control table reservation counter increment */
107 /* Mutex handling Functions for Accessing Message Control Tables */
108 static void MsgCreateMutex(void); /* Mutex generating */
109 /* Message send handle setting */
110 /* static void MsgDeleteMutex(void); */ // Todo:Uncomment out after completion of implementation of termination processing
111 static void MsgLockMutex(void); /* Mutex retrieval */
112 static void MsgUnlockMutex(void); /* Mutex release */
114 /*---------------------------------------------------------------------------------*
116 *---------------------------------------------------------------------------------*/
119 * Initialize the message function
121 * Message control table initialization
123 * @return RET_NORMAL Normal completion<br>
124 * RET_ERRPARAM Parameter error
126 RET_API MsgInit(void) {
127 RET_API ret_api = RET_NORMAL;
132 /* Control table initialization */
133 memset(g_msg_ctrl_tbl.info, 0x00, sizeof(g_msg_ctrl_tbl.info));
135 for (i = 0; i < MSG_MAX_NUM_CTRL_MSGQUE; i++) {
136 /* Empty character is set for the message queue name. */
137 _tcscpy(g_msg_ctrl_tbl.info[i].name, "");
139 g_msg_ctrl_tbl.use_cnt = 0;
140 g_msg_ctrl_tbl.rsv_cnt = 0;
149 * @return RET_NORMAL Normal completion<br>
152 RET_API MsgTerm(void) { // LCOV_EXCL_START 8:dead code
153 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
154 RET_API ret_api = RET_ERROR;
156 EFrameworkunifiedStatus estatus;
163 /* Release Message Transmission/Reception Handle */
164 for (idx = 0; idx < MSG_MAX_NUM_CTRL_MSGQUE; idx++) {
165 /* Receive handle acquisition */
166 pno = MsgGetPnoOfCtrlTbl(idx);
168 /* For queue information for internal threads */
169 /* Delete Message Queue */
170 ret = PbDeleteMsg(pno);
171 if (ret != RET_NORMAL) {
172 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "McClose ERROR " \
173 "[ret:%d, pno:%d]", ret, pno);
174 /* The module returns OK even if it fails. */
177 /* Other than the above(Send handle to external process) */
178 /* Get send handle */
179 handle = MsgGetSenderHandleOfCtrlTbl(idx);
180 if (handle != NULL) {
181 estatus = FrameworkunifiedMcClose(handle);
182 if (estatus != eFrameworkunifiedStatusOK) {
183 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "FrameworkunifiedMcClose ERROR " \
184 "[estatus:%d, handle:%p]", estatus, handle);
185 /* The module returns OK even if it fails. */
187 /* Message control table update */
188 MsgSetSenderHandleOfCtrlTbl(idx, NULL); /* Send handle */
190 MsgSetNameOfCtrlTbl(idx, ""); /* Name */
193 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
194 "(--) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s",
195 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, \
196 PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
197 MsgGetNameOfCtrlTbl(idx));
204 /* MsgDeleteMutex(); */ // Todo:Uncomment out after completion of implementation of termination processing
206 /* TODO:Delete the shared memory for the message management table */
214 * Create the message queue
216 * Creates a message queue.
217 * This function is implemented on the assumption that a thread name is assigned by prctl() and then called from that thread.
218 * The generated message queue name is the same as the thread name.
220 * @param[in] pno Process number
222 * @return RET_NORMAL Normal completion<br>
223 * RET_ERRPARAM Parameter error<br>
224 * RET_ERROR Other errors
226 RET_API _pb_CreateMsg(PNO pno) { // NOLINT(readability/nolint) interface
227 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
229 HANDLE handle = NULL;
230 char name[MAX_QUEUE_NAME_SIZE];
233 /* If PNO is invalid (0), the parameter is abnormal and processing is not performed. */
235 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [pno:%d]", pno);
236 ret_api = RET_ERRPARAM;
238 /* Get Thread Name */
239 (void)prctl(PR_GET_NAME, name);
242 if (len >= MAX_QUEUE_NAME_SIZE) {
243 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Length of thread name is too long(>=%d). " \
244 "[len:%zu]", MAX_QUEUE_NAME_SIZE, len);
245 ret_api = RET_ERRPARAM;
247 MsgLockMutex(); // LCOV_EXCL_BR_LINE 200: no branch
249 /* Check if the specified PNO is already registered */
250 idx = MsgSearchPnoOfCtrlTbl(pno); // LCOV_EXCL_BR_LINE 200: no branch
252 /* When the entry is already stored */
253 if (idx != MSG_MAX_NUM_CTRL_MSGQUE) {
255 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
256 "(+) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s", \
257 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, \
258 PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
259 MsgGetNameOfCtrlTbl(idx));
262 /* Search for free space */
263 idx = MsgSearchEmptyOfCtrlTbl();
264 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 200: idx can not be MSG_MAX_NUM_CTRL_MSGQUE
265 /* Be impossible by design */
266 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchEmptyOfCtrlTbl ERROR " \
268 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
269 _pb_Exit(); // LCOV_EXCL_LINE 200: idx can not be MSG_MAX_NUM_CTRL_MSGQUE
271 /* don't arrive here. */
273 /* Create Message Queue */
274 handle = McOpenReceiver(name); // LCOV_EXCL_BR_LINE 4: nsfw error
275 if (handle == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
276 /* In the event of failure */
277 // LCOV_EXCL_START 5: standard lib error
278 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
279 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenReceiver ERROR " \
280 "[handle:%p, name:%s]", handle, name);
283 /* don't arrive here. */
286 /* Message control table update */
287 MsgSetPnoOfCtrlTbl(idx, pno); /* PNO */ // LCOV_EXCL_BR_LINE 200: no branch
289 MsgSetReceiverHandleOfCtrlTbl(idx, handle); /* Receive handle */ // LCOV_EXCL_BR_LINE 200: no branch // NOLINT(whitespace/line_length)
291 MsgSetNameOfCtrlTbl(idx, name); /* Name */ // LCOV_EXCL_BR_LINE 200: no branch
293 /* Increment Message Control Table Usage Counter */
294 MsgIncUseCntOfCtrlTbl();
296 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, \
297 "### MESSAGE TABLE INFORMATION # (++) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, " \
298 "h_sender=%p, h_receiver=%p, name=%s", idx, MsgGetPnoOfCtrlTbl(idx), \
299 PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, PbGetLocalTid()), \
300 MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
301 MsgGetNameOfCtrlTbl(idx));
306 MsgUnlockMutex(); // LCOV_EXCL_BR_LINE 200: no branch
315 * Delete the message queue
317 * Delete a message queue.
318 * Deleted from the message control table even if closing of the send/receive handle fails
322 * @return RET_NORMAL Normal completion
324 RET_API PbDeleteMsg(PNO pno) { // LCOV_EXCL_START 8:dead code
325 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
326 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
330 EFrameworkunifiedStatus estatus;
332 idx = MsgSearchPnoOfCtrlTbl(pno);
333 if (idx != MSG_MAX_NUM_CTRL_MSGQUE) {
334 /* Receive handle acquisition */
335 handle = MsgGetReceiverHandleOfCtrlTbl(idx);
336 if (handle != NULL) {
337 estatus = McClose(handle);
338 if (estatus != eFrameworkunifiedStatusOK) {
339 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "McClose ERROR " \
340 "[estatus:%d, handle:%p]", estatus, handle);
341 /* The module returns OK even if the Close fails. */
345 /* Get send handle */
346 handle = MsgGetSenderHandleOfCtrlTbl(idx);
347 if (handle != NULL) {
348 estatus = McClose(handle);
349 if (estatus != eFrameworkunifiedStatusOK) {
350 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "McClose ERROR " \
351 "[estatus:%d, handle:%p]", estatus, handle);
352 /* The module returns OK even if the Close fails. */
356 /* Get send handle */
357 handle = MsgGetZcSenderHandleOfCtrlTbl(idx);
358 if (handle != NULL) {
359 estatus = McZcClose(handle);
360 if (estatus != eFrameworkunifiedStatusOK) {
361 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "McZcClose ERROR " \
362 "[estatus:%d, handle:%p]", estatus, handle);
363 /* The module returns OK even if the Close fails. */
367 /* Message control table update */
368 MsgSetPnoOfCtrlTbl(idx, 0); /* PNO */
370 for (i = 0; i < MSG_MAX_NUM_CTRL_THREAD; i++) {
371 MsgSetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, NULL, i); /* Send handle */
374 MsgSetSenderHandleOfCtrlTbl(idx, NULL); /* Send handle */
376 MsgSetReceiverHandleOfCtrlTbl(idx, NULL); /* Receive handle */
378 MsgSetNameOfCtrlTbl(idx, ""); /* Name */
380 /* Decrement Message Control Table Usage Counter */
381 MsgDecUseCntOfCtrlTbl();
383 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
384 "(--) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s", \
385 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, \
386 PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
387 MsgGetNameOfCtrlTbl(idx));
396 * Receive the message
398 * Receive a message for the specified PNO.If the specified PNO is invalid, an error is returned.
399 * If the size of the received data exceeds the size specified in the parameter, an error is returned.
401 * @param[in] pno Process number
402 * @param[in] size Message size
403 * @param[out] msgbuf Pointer to message area
404 * @param[in] mode Not used
406 * @return RET_NORMAL Normal completion<br>
407 * RET_ERRPARAM Parameter error<br>
408 * RET_ERROR Other errors
410 RET_API _pb_RcvMsg(PNO pno, u_int16 size, void** msgbuf, u_int16 mode) { // NOLINT(readability/nolint) interface
411 RET_API ret_api = RET_RCVMSG; /* Results of this Module process */
413 HANDLE h_msg_que = NULL;
414 char source[MAX_QUEUE_NAME_SIZE];
416 EFrameworkunifiedStatus rcv_sts;
417 u_int8* p_msg_rcv_buf;
422 if (msgbuf == NULL) {
423 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [msgbuf:%p]", msgbuf);
424 ret_api = RET_ERRPARAM;
425 } else if (pno == 0) {
426 /* PNO-invalid Check */
427 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [pno:%d]", pno);
428 ret_api = RET_ERRPARAM;
430 /* Search if the specified PNO is registered in the control table */
431 idx = MsgSearchPnoOfCtrlTbl(pno); // LCOV_EXCL_BR_LINE 200: no branch
433 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) {
434 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchPnoOfCtrlTbl ERROR " \
435 "[idx:%d, pno:0x%x]", idx, pno);
436 ret_api = RET_ERRPARAM;
438 /* If it is registered */
439 /* Handle acquisition */
440 h_msg_que = MsgGetReceiverHandleOfCtrlTbl(idx); // LCOV_EXCL_BR_LINE 200: recv handle created in _pb_CreateMsg //NOLINT(whitespace/line_length)
441 if (h_msg_que == NULL) { // LCOV_EXCL_BR_LINE 200: recv handle created in _pb_CreateMsg
442 /* Be impossible by design */
443 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Msg_getMsgQueHandleOfCtrlTbl ERROR " \
444 "[h_msg_que:%p, idx:%d]", h_msg_que, idx);
445 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
446 _pb_Exit(); // LCOV_EXCL_LINE 200: recv handle created in _pb_CreateMsg
448 /* don't arrive here. */
451 /* Get Message Buffer */
452 p_msg_rcv_buf = MsgGetMsgRcvBufOfCtrlTbl(idx); // LCOV_EXCL_BR_LINE 200: no branch
454 /* Receive message */
455 // LCOV_EXCL_BR_START 4: nsfw error
456 rcv_sts = McReceive(h_msg_que,
457 source, /* app that sent this message */
458 &cmd_id, /* Command ID */
460 (PVOID)p_msg_rcv_buf);
463 if (rcv_sts != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
464 /* In the event of failure */
465 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McReceive ERROR " \
466 "[rcv_sts:%d, h_msg_que:%p, source:%s, cmd_id:0x%x]", rcv_sts, h_msg_que, source, cmd_id);
467 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
468 ret_api = RET_ERROR; // LCOV_EXCL_LINE 4: nsfw error
472 msg_len = McGetLength(p_msg_rcv_buf); // LCOV_EXCL_BR_LINE 4: nsfw error
473 if ((msg_len <= size) && (msg_len > 0)) { // LCOV_EXCL_BR_LINE 4: nsfw error
476 p_rcv_data = McGetDataPointer(p_msg_rcv_buf); // LCOV_EXCL_BR_LINE 4: nsfw error
477 if (p_rcv_data == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
478 // LCOV_EXCL_START 4: nsfw error
479 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
480 rcv_sts = McGetDataOfSize(p_msg_rcv_buf, *msgbuf, msg_len);
481 if (rcv_sts != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
482 /* Message acquisition failure */
483 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
484 "McGetDataOfSize ERROR [rcv_sts:%d]", rcv_sts);
488 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, \
489 "McReceive/McGetDataOfSize SUCCESS [rcv_sts:%d, h_msg_que:%p, source:%s, " \
490 "cmd_id:0x%x, msg_len:%d]", rcv_sts, h_msg_que, source, cmd_id, msg_len);
493 *msgbuf = p_rcv_data;
497 // LCOV_EXCL_START 4: nsfw error
498 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
499 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McGetLength ERROR " \
500 "[size:%d < msg_len:%d]", size, msg_len);
515 * For in-process communication
516 * Sends a message to the specified PNO.If the specified PNO is invalid, an error is returned.
518 * @param[in] pno Process number
519 * @param[in] size Message size
520 * @param[in] msgbuf Pointer to message storage area
521 * @param[in] mode Not used
523 * @return RET_NORMAL Normal completion<br>
524 * RET_ERRPARAM Parameter error<br>
525 * RET_ERROR Other errors
527 RET_API _pb_SndMsg(PNO pno, u_int16 size, void* msgbuf, u_int16 mode) { // NOLINT(readability/nolint) interface
528 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
531 HANDLE handle; /* handle to the send message queue */
532 EFrameworkunifiedStatus estatus;
533 T_APIMSG_MSGBUF_HEADER *p_msg_header;
537 if (msgbuf == NULL) {
538 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [msgbuf:%p]", msgbuf);
539 ret_api = RET_ERRPARAM;
540 } else if (pno == 0) {
541 /* PNO-invalid Check */
542 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [pno:%d]", pno);
543 ret_api = RET_ERRPARAM;
547 /* Check if the specified PNO is registered in the message control table */
548 idx = MsgSearchPnoOfCtrlTbl(pno);
549 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) {
551 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchPnoOfCtrlTbl ERROR!! " \
554 ret_api = RET_ERRPARAM;
556 /* If it is registered */
557 /* Acquire transmission handle from management table */
558 handle = MsgGetSenderHandleOfCtrlTbl(idx);
559 if (handle == NULL) {
560 /* Get message queue name */
561 msg_que_name = MsgGetNameOfCtrlTbl(idx);
563 /* Get send handle */
564 handle = McOpenSender(msg_que_name); // LCOV_EXCL_BR_LINE 4: nsfw error
565 /* When handle acquisition fails */
566 if (handle == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
567 // LCOV_EXCL_START 4: nsfw error
568 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
569 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender ERROR " \
570 "[handle:%p, msg_que_name:%s]", handle, msg_que_name);
576 /* Message control table update */
577 MsgSetSenderHandleOfCtrlTbl(idx, handle); /* Send handle */
579 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
580 "(+) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s", \
581 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, \
582 PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
583 MsgGetNameOfCtrlTbl(idx));
585 /* When handle acquisition is successful */
586 if (handle != NULL) {
587 p_msg_header = reinterpret_cast<T_APIMSG_MSGBUF_HEADER*>(msgbuf);
588 cid = p_msg_header->hdr.cid;
591 estatus = McSend(handle,
592 "", /* Sender name */
593 cid, /* Command ID */
595 msgbuf); // LCOV_EXCL_BR_LINE 4: nsfw error
596 /* When transmission fails */
597 if (estatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
598 // LCOV_EXCL_START 4: nsfw error
599 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
600 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend ERROR " \
601 "[estatus:%d, idx:%d, handle:%p, cid:0x%x, size:%d]", estatus, idx, handle, cid, size);
605 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "McSend SUCCESS " \
606 "[estatus:%d, idx:%d, handle:%p, cid:0x%x, size:%d]", estatus, idx, handle, cid, size);
609 /* Close all handles at the time of termination */
621 * Acquire transmission buffer for in-process communication (for non-copy API)
622 * Gets the buffer for sending messages to the specified PNO.If the specified PNO is invalid, an error is returned.
623 * Set the send data in the acquired buffer and send it with _pb_ZcSndMsg().
625 * @param[in] pno Process number
626 * @param[out] p_snd_buf Transmitting buffer
628 * @return RET_NORMAL Normal completion<br>
629 * RET_ERRPARAM Parameter error<br>
630 * RET_ERROR Other errors
632 RET_API _pb_GetZcSndBuf(PNO pno, void** p_snd_buf) { // NOLINT(readability/nolint) interface
633 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
636 HANDLE handle; /* handle to the send message queue */
638 /* PNO-invalid Check */
640 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [pno:%d]", pno);
641 ret_api = RET_ERRPARAM;
645 /* Check if the specified PNO is registered in the message control table */
646 idx = MsgSearchPnoOfCtrlTbl(pno);
647 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) {
649 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchPnoOfCtrlTbl ERROR!! [pno=%d]", pno);
651 ret_api = RET_ERRPARAM;
653 /* If it is registered */
654 /* Acquire transmission handle from management table */
655 handle = MsgGetZcSenderHandleOfCtrlTbl(idx);
656 if (handle == NULL) {
657 /* Get message queue name */
658 msg_que_name = MsgGetNameOfCtrlTbl(idx);
660 /* Get send handle */
661 handle = McZcOpenSender(msg_que_name); // LCOV_EXCL_BR_LINE 4: nsfw error
662 if (handle == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
663 // LCOV_EXCL_START 4: nsfw error
664 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
665 /* When handle acquisition fails */
666 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender ERROR " \
667 "[handle:%p, msg_que_name:%s]", handle, msg_que_name);
673 /* Message control table update */
674 MsgSetZcSenderHandleOfCtrlTbl(idx, handle); /* Send handle */
676 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
677 "(+) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s",
678 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, \
679 PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
680 MsgGetNameOfCtrlTbl(idx));
683 if (handle != NULL) {
684 /* When handle acquisition is successful */
685 /* Get message send buffer */
686 *p_snd_buf = McZcGetBuf(handle); // LCOV_EXCL_BR_LINE 4: nsfw error
687 if (*p_snd_buf == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
688 // LCOV_EXCL_START 4: nsfw error
689 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
690 /* When buffer acquisition fails */
691 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McZcSetParam ERROR " \
692 "[idx:%d, handle:%p]", idx, handle);
697 /* Close all handles at the time of termination */
711 * For in-process communication(for non-copy API)
712 * Sends a message to the specified PNO.If the specified PNO is invalid, an error is returned.
713 * Before calling this function, send data must be set in the area acquired by _pb_GetZcSndBuf().
715 * @param[in] pno Process number
716 * @param[in] size Message size
717 * @param[in] mode Not used
719 * @return RET_NORMAL Normal completion<br>
720 * RET_ERRPARAM Parameter error<br>
721 * RET_ERROR Other errors
723 RET_API _pb_ZcSndMsg(PNO pno, u_int16 size, u_int16 mode) { // NOLINT(readability/nolint) interface
724 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
726 HANDLE handle; /* handle to the send message queue */
727 EFrameworkunifiedStatus estatus;
728 T_APIMSG_MSGBUF_HEADER *p_msg_header;
732 /* PNO-invalid Check */
734 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [pno:%d]", pno);
735 ret_api = RET_ERRPARAM;
739 /* Check if the specified PNO is registered in the message control table */
740 idx = MsgSearchPnoOfCtrlTbl(pno);
741 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) {
743 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchPnoOfCtrlTbl ERROR!! [pno=%d]", pno);
745 ret_api = RET_ERRPARAM;
747 /* If it is registered */
748 /* Acquire transmission handle from management table */
749 handle = MsgGetZcSenderHandleOfCtrlTbl(idx); // LCOV_EXCL_BR_LINE 200: sender handle set in _pb_GetZcSndBuf
750 if (handle == NULL) { // LCOV_EXCL_BR_LINE 200: sender handle set in _pb_GetZcSndBuf
751 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "handle ERROR " \
752 "[pno=%d, idx=%d]", pno, idx);
754 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
755 ret_api = RET_ERROR; // LCOV_EXCL_LINE 200: sender handle set in _pb_GetZcSndBuf
757 /* When handle acquisition is successful */
758 if (handle != NULL) {
760 /* Set the transmission data in advance. */
761 p_send_data = McZcGetBuf(handle);
762 if (p_send_data != NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
763 p_msg_header = reinterpret_cast<T_APIMSG_MSGBUF_HEADER*>(p_send_data);
764 cid = p_msg_header->hdr.cid;
765 estatus = McZcSetParam(handle, cid, size);
766 if (estatus == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
767 estatus = McZcSend(handle); // LCOV_EXCL_BR_LINE 4: nsfw error
768 /* When transmission fails */
769 if (estatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
770 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McZcSend ERROR " \
771 "[estatus:%d, idx:%d, handle:%p, cid:0x%x, size:%d]", estatus, \
772 idx, handle, cid, size);
773 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
774 ret_api = RET_ERROR; // LCOV_EXCL_LINE 4: nsfw error
776 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "McZcSend SUCCESS " \
777 "[estatus:%d, idx:%d, handle:%p, cid:0x%x, size:%d]", estatus, \
778 idx, handle, cid, size);
781 /* When parameter setting fails */
782 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McZcSetParam ERROR " \
783 "[estatus:%d, idx:%d, handle:%p, cid:0x%x, size:%d]", estatus, idx, handle, cid, size);
787 /* When parameter buffer acquisition fails */
788 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McZcGetBuf ERROR " \
789 "[idx:%d, handle:%p, size:%d]", idx, handle, size);
793 /* Close all handles at the time of termination */
807 * For interprocess communication
808 * Sends a message to the specified process.If the specified process is invalid, an error is returned.
810 * Note: Since the data sent by this function is to be received by the dispatcher, the message header
811 * must not be included in the send data specified by the argument.
813 * @param[in] name Destination Process Name
814 * @param[in] cid Command ID
815 * @param[in] size Message size
816 * @param[in] msgbuf Pointer to message storage area
817 * @param[in] mode Not used
819 * @return RET_NORMAL Normal completion<br>
820 * RET_ERRPARAM Parameter error<br>
821 * RET_ERROR Other errors
823 RET_API _pb_SndMsg_Ext(PCSTR name, CID cid, u_int16 size, const void* msgbuf, // NOLINT(readability/nolint) interface
825 RET_API ret_api = RET_NORMAL; /* Results of this Module process */
826 uint32_t thread_offset;
828 HANDLE h_positioningbaselibrary_service = NULL;
829 EFrameworkunifiedStatus estatus;
834 if ((name == NULL) || (msgbuf == NULL)) {
835 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR " \
836 "[name:%p, msgbuf:%p]", name, msgbuf);
837 ret_api = RET_ERRPARAM;
839 h_app = _pb_GetAppHandle();
842 if (len >= MAX_QUEUE_NAME_SIZE) {
843 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR!! " \
844 "Length of thread name is too long(>=%d). [len:%zu]", MAX_QUEUE_NAME_SIZE, len);
845 ret_api = RET_ERRPARAM;
847 thread_offset = PbGetLocalTid();
851 idx = MsgSearchNameOfCtrlTbl(name);
853 if (idx != MSG_MAX_NUM_CTRL_MSGQUE) {
854 h_positioningbaselibrary_service = MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, thread_offset);
855 if (h_positioningbaselibrary_service == NULL) {
856 h_positioningbaselibrary_service = FrameworkunifiedMcOpenSender(h_app, name); // LCOV_EXCL_BR_LINE 4: nsfw error
857 /* When handle acquisition fails */
858 if (h_positioningbaselibrary_service == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
859 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedMcOpenSender ERROR!! " \
860 "[h_positioningbaselibrary_service=%p, h_app=%p, name=%s]", h_positioningbaselibrary_service, h_app, name);
861 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
862 ret_api = RET_ERROR; // LCOV_EXCL_LINE 4: nsfw error
864 /* Message control table update */
865 MsgSetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, h_positioningbaselibrary_service, thread_offset); /* Send handle */
867 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### MESSAGE TABLE INFORMATION # " \
868 "(+) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, h_sender=%p, h_receiver=%p, name=%s", \
869 idx, MsgGetPnoOfCtrlTbl(idx), PbGetLocalTid(), \
870 MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, PbGetLocalTid()), MsgGetSenderHandleOfCtrlTbl(idx), \
871 MsgGetReceiverHandleOfCtrlTbl(idx), MsgGetNameOfCtrlTbl(idx));
875 /* Search for free space */
876 idx = MsgSearchEmptyOfCtrlTbl();
877 if (idx == MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 200: idx can not be MSG_MAX_NUM_CTRL_MSGQUE
878 /* Be impossible by design */
879 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgSearchEmptyOfCtrlTbl ERROR!! " \
881 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
882 _pb_Exit(); // LCOV_EXCL_LINE 200: idx can not be MSG_MAX_NUM_CTRL_MSGQUE
884 /* don't arrive here. */
886 /* Get send handle */
887 h_positioningbaselibrary_service = FrameworkunifiedMcOpenSender(h_app, name); // LCOV_EXCL_BR_LINE 4: nsfw error
888 /* When handle acquisition fails */
889 if (h_positioningbaselibrary_service == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
890 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedMcOpenSender ERROR!! " \
891 "[h_positioningbaselibrary_service=%p, h_app=%p, name=%s]", h_positioningbaselibrary_service, h_app, name);
892 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
893 ret_api = RET_ERROR; // LCOV_EXCL_LINE 4: nsfw error
895 /* Message control table update */
896 MsgSetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, h_positioningbaselibrary_service, thread_offset); /* Send handle */
898 MsgSetNameOfCtrlTbl(idx, name); /* Name */
900 /* Increment Message Control Table Usage Counter */
901 MsgIncUseCntOfCtrlTbl();
903 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, \
904 "### MESSAGE TABLE INFORMATION # (++) idx=%d, pno=%d, h_positioningbaselibrary_sender[%d]=%p, " \
905 "h_sender=%p, h_receiver=%p, name=%s", idx, MsgGetPnoOfCtrlTbl(idx), \
906 PbGetLocalTid(), MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(idx, PbGetLocalTid()), \
907 MsgGetSenderHandleOfCtrlTbl(idx), MsgGetReceiverHandleOfCtrlTbl(idx), \
908 MsgGetNameOfCtrlTbl(idx));
914 /* When handle acquisition is successful */
915 if (h_positioningbaselibrary_service != NULL) {
917 estatus = FrameworkunifiedSendMsg(h_positioningbaselibrary_service, cid, size, msgbuf); // LCOV_EXCL_BR_LINE 4: nsfw error
918 /* When transmission fails */
919 if (estatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: nsfw error
920 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg ERROR!! " \
921 "[name=%s, estatus=%d, h_positioningbaselibrary_service=%p, cid=%d, size=%d]", \
922 name, estatus, h_positioningbaselibrary_service, cid, size);
923 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
924 ret_api = RET_ERROR; // LCOV_EXCL_LINE 4: nsfw error
926 FRAMEWORKUNIFIEDLOG(ZONE_17, __FUNCTION__, "Send message = " \
927 "[Destination:%s][CID:0x%X]", name, cid);
929 /* Close all handles at the time of termination */
937 /*---------------------------------------------------------------------------------*
939 *---------------------------------------------------------------------------------*/
942 * PNO setting(Message control table)
944 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
946 * @param[in] idx Control Table Element Number
947 * @param[in] pno Process number
949 static void MsgSetPnoOfCtrlTbl(u_int32 idx, PNO pno) {
951 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
953 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d, pno:%d]", idx, pno);
954 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
955 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
957 /* don't arrive here. */
959 g_msg_ctrl_tbl.info[idx].pno = pno;
967 * PNO acquisition(Message control table)
969 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
971 * @param[in] idx Control Table Element Number
972 * @param[in] pno Process number
974 static PNO MsgGetPnoOfCtrlTbl(u_int32 idx) {
976 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
978 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
979 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
980 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
982 /* don't arrive here. */
985 return g_msg_ctrl_tbl.info[idx].pno;
990 * Message queue name setting(Message control table)
992 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
994 * @param[in] idx Control Table Element Number
995 * @param[in] name Message queue name
997 static void MsgSetNameOfCtrlTbl(u_int32 idx, LPCTSTR name) {
999 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1001 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d, name:%s]", idx, name);
1002 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1003 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1005 /* don't arrive here. */
1008 _tcscpy(g_msg_ctrl_tbl.info[idx].name, name);
1015 * Get Message Queue Name(Message control table)
1017 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1019 * @param[in] idx Control Table Element Number
1021 * @return Message queue name
1023 static char* MsgGetNameOfCtrlTbl(u_int32 idx) {
1025 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1027 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1028 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1029 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1031 /* don't arrive here. */
1034 return g_msg_ctrl_tbl.info[idx].name;
1039 * Message reception handle setting(Message control table)
1041 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1043 * @param[in] idx Control Table Element Number
1044 * @param[in] handle Message queue handle
1046 static void MsgSetReceiverHandleOfCtrlTbl(u_int32 idx, HANDLE handle) {
1048 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1050 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR " \
1051 "[idx:%d, handle:%p]", idx, handle);
1052 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1053 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1055 /* don't arrive here. */
1057 g_msg_ctrl_tbl.info[idx].h_receiver = handle;
1065 * Get message reception handle(Message control table)
1067 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1069 * @param[in] idx Control Table Element Number
1071 * @return Message queue handle
1073 static HANDLE MsgGetReceiverHandleOfCtrlTbl(u_int32 idx) {
1075 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1077 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1078 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1079 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1081 /* don't arrive here. */
1084 return g_msg_ctrl_tbl.info[idx].h_receiver;
1089 * Message send handle setting(Message control table)
1091 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1093 * @param[in] idx Control Table Element Number
1094 * @param[in] handle Message queue handle
1096 static void MsgSetSenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle) {
1098 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1100 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR " \
1101 "[idx:%d, handle:%p]", idx, handle);
1102 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1103 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1105 /* don't arrive here. */
1107 g_msg_ctrl_tbl.info[idx].h_sender = handle;
1115 * Get message send handle(Message control table)
1117 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1119 * @param[in] idx Control Table Element Number
1121 * @return Message queue handle
1123 static HANDLE MsgGetSenderHandleOfCtrlTbl(u_int32 idx) {
1125 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1127 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1128 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1129 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1131 /* don't arrive here. */
1134 return g_msg_ctrl_tbl.info[idx].h_sender;
1140 * Positioningbaselibrary message send handle setting(Message control table)
1142 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1144 * @param[in] idx Control Table Element Number
1145 * @param[in] handle Message queue handle
1146 * @param[in] offset Local thread ID
1148 static void MsgSetPositioningbaselibrarySenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle, uint32_t offset) {
1150 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1152 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR " \
1153 "[idx:%d, handle:%p]", idx, handle);
1154 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1155 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1157 /* don't arrive here. */
1159 g_msg_ctrl_tbl.info[idx].h_positioningbaselibrary_sender[offset] = handle;
1167 * Positioningbaselibrary message send handle acquisition(Message control table)
1169 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1171 * @param[in] idx Control Table Element Number
1172 * @param[in] offset Local thread ID
1174 * @return Message queue handle
1176 static HANDLE MsgGetPositioningbaselibrarySenderHandleOfCtrlTbl(u_int32 idx, uint32_t offset) {
1178 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1180 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1181 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1182 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1184 /* don't arrive here. */
1187 return g_msg_ctrl_tbl.info[idx].h_positioningbaselibrary_sender[offset];
1192 * Message send handle setting(Message control table)
1194 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1196 * @param[in] idx Control Table Element Number
1197 * @param[in] handle Message queue handle
1199 static void MsgSetZcSenderHandleOfCtrlTbl(u_int32 idx, HANDLE handle) {
1201 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1203 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR " \
1204 "[idx:%d, handle:%p]", idx, handle);
1205 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1206 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1208 /* don't arrive here. */
1210 g_msg_ctrl_tbl.info[idx].h_zc_sender = handle;
1218 * Get message send handle(Message control table)
1220 * If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
1222 * @param[in] idx Control Table Element Number
1224 * @return Message queue handle
1226 static HANDLE MsgGetZcSenderHandleOfCtrlTbl(u_int32 idx) {
1228 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1230 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1231 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1232 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1234 /* don't arrive here. */
1237 return g_msg_ctrl_tbl.info[idx].h_zc_sender;
1242 * Get message receive buffer(Message control table)
1244 * @param[in] idx Control Table Element Number
1246 * @return Pointer to message receive buffer
1248 static uint8_t* MsgGetMsgRcvBufOfCtrlTbl(uint32_t idx) {
1250 if (idx >= MSG_MAX_NUM_CTRL_MSGQUE) { // LCOV_EXCL_BR_LINE 6: idx cannot greater
1252 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [idx:%d]", idx);
1253 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1254 _pb_Exit(); // LCOV_EXCL_LINE 6: idx cannot greater
1256 /* don't arrive here. */
1259 return g_msg_ctrl_tbl.info[idx].msg_rcv_buf;
1264 * Search unused area(Message control table)
1266 * Returns the index (minimum value) for accessing the unused area in the message control table.<br>
1267 * Returns the maximum message queue management value (MSG_MAX_NUM_CTRL_MSGQUE) <br>
1268 * when no unused area exists
1270 * @return Index for access(Unused area exists.)<br>
1271 * Maximum mutex management value(No unused area)
1273 static u_int32 MsgSearchEmptyOfCtrlTbl(void) {
1277 for (idx = 0; idx < MSG_MAX_NUM_CTRL_MSGQUE; idx++) {
1278 ret = _tcscmp(g_msg_ctrl_tbl.info[idx].name, "");
1280 /* For unused space */
1291 * PNO search(Message control table)
1293 * Retrieves whether the specified PNO is already registered in the message control table.<br>
1294 * If it is registered, the access index is returned.If it is not stored,<br>
1295 * Returns the maximum message queue management value (MSG_MAX_NUM_CTRL_MSGQUE).
1297 * @param[in] pno Process number
1299 * @return Index for access(If it is registered)<br>
1300 * Maximum value of message queue management(Not stored)
1302 static u_int32 MsgSearchPnoOfCtrlTbl(PNO pno) {
1306 for (idx = 0; idx < MSG_MAX_NUM_CTRL_MSGQUE; idx++) {
1307 lPno = MsgGetPnoOfCtrlTbl(idx);
1309 /* If there is a match */
1321 * Queue name search(Message control table)
1323 * Retrieves whether the specified queue name is already registered in the message control table.<br>
1324 * If it is registered, the access index is returned.If it is not stored,<br>
1325 * Returns the maximum message queue management value (MSG_MAX_NUM_CTRL_MSGQUE).
1327 * @param[in] Name queue-name
1329 * @return Index for access(If it is registered)<br>
1330 * Maximum value of message queue management(Not stored)
1332 static u_int32 MsgSearchNameOfCtrlTbl(LPCTSTR name) {
1336 for (idx = 0; idx < MSG_MAX_NUM_CTRL_MSGQUE; idx++) {
1337 ret = _tcscmp(g_msg_ctrl_tbl.info[idx].name, name);
1339 /* If there is a match */
1351 * Creation of Mutex for accessing the message control table
1353 static void MsgCreateMutex(void) {
1354 g_h_mtx = _pb_CreateMutex(NULL, 0, "Msg_Mutex");
1355 if (g_h_mtx == NULL) { // LCOV_EXCL_BR_LINE 200: can not be not NULL
1356 // LCOV_EXCL_START 200: can not be not NULL
1357 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1358 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_CreateMutex ERROR [g_h_mtx:%p]", g_h_mtx);
1362 /* don't arrive here. */
1370 * Acquire Mutex for accessing the message control table
1372 static void MsgLockMutex(void) {
1374 ret = PbMutexLock(g_h_mtx, INFINITE); // LCOV_EXCL_BR_LINE 200: mutex lock can not failed
1375 if (ret != WAIT_OBJECT_0) { // LCOV_EXCL_BR_LINE 200: mutex lock can not failed
1376 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PbMutexLock ERROR " \
1377 "[ret:%lu, g_h_mtx:%p]", ret, g_h_mtx);
1378 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1379 _pb_Exit(); // LCOV_EXCL_LINE 200: mutex lock can not failed
1381 /* don't arrive here. */
1389 * Releasing the Mutex for accessing the message control table
1391 static void MsgUnlockMutex(void) {
1393 ret = PbMutexUnlock(g_h_mtx); // LCOV_EXCL_BR_LINE 200: mutex lock can not failed
1394 if (ret != TRUE) { // LCOV_EXCL_BR_LINE 200: mutex lock can not failed
1395 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PbMutexUnlock ERROR " \
1396 "[ret:%d, g_h_mtx:%p]", ret, g_h_mtx);
1397 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1398 _pb_Exit(); // LCOV_EXCL_LINE 200: mutex lock can not failed
1400 /* don't arrive here. */
1408 * Obtain dump information
1410 * @param[out] pBuf Dump info
1411 * @param[in/out] pLen Buffer size
1413 void _pb_GetDebugMsgMngTbl(void* pBuf, uint8_t* pLen) {
1414 static uint8_t buf[DEBUG_DUMP_MAX_SIZE];
1415 static uint8_t bufPositioningbaselibrarySender[DEBUG_DUMP_MAX_SIZE];
1416 static uint8_t bufTmp[DEBUG_DUMP_MAX_SIZE];
1417 static uint8_t bufMsg[DEBUG_DUMP_MAX_SIZE];
1422 if ((pBuf != NULL) && (pLen != NULL)) {
1423 memset(&buf[0], 0x00, sizeof(buf));
1424 memset(&bufMsg[0], 0x00, sizeof(bufMsg));
1425 for (i = 0; i < MSG_MAX_NUM_CTRL_MSGQUE; i++) {
1426 memset(&bufPositioningbaselibrarySender[0], 0x00, sizeof(bufPositioningbaselibrarySender));
1427 for (e = 0; e < MSG_MAX_NUM_CTRL_THREAD; e++) {
1428 memset(&bufTmp[0], 0x00, sizeof(bufTmp));
1429 snprintf(reinterpret_cast<char *>(&bufTmp[0]), sizeof(bufTmp),
1430 "[%02d]%10p ", e, g_msg_ctrl_tbl.info[i].h_positioningbaselibrary_sender[e]);
1431 strncat(reinterpret_cast<char *>(&bufPositioningbaselibrarySender[0]), reinterpret_cast<char *>(&bufTmp[0]), \
1432 strlen(reinterpret_cast<char *>(&bufTmp[0])));
1434 memset(&bufTmp[0], 0x00, sizeof(bufTmp));
1435 snprintf(reinterpret_cast<char *>(&bufTmp[0]), sizeof(bufTmp),
1436 "\n [%02d] pno:0x%04x, name:%16s, hSnd:%10p, hRcv:%10p, hPSnd:%s",
1438 g_msg_ctrl_tbl.info[i].pno,
1439 g_msg_ctrl_tbl.info[i].name,
1440 g_msg_ctrl_tbl.info[i].h_sender,
1441 g_msg_ctrl_tbl.info[i].h_receiver,
1442 &bufPositioningbaselibrarySender[0]);
1443 strncat(reinterpret_cast<char *>(&bufMsg[0]), reinterpret_cast<char *>(&bufTmp[0]), \
1444 strlen(reinterpret_cast<char *>(&bufTmp[0])));
1445 if (((i+1) % 8) == 0) {
1447 memset(&buf[0], 0x00, sizeof(buf));
1448 snprintf(reinterpret_cast<char *>(&buf[0]), sizeof(buf),
1452 memcpy(pBuf, &buf[0], sizeof(buf));
1453 pBuf = reinterpret_cast<void *>((reinterpret_cast<uint8_t *>(pBuf)) + sizeof(buf));
1454 memset(&bufMsg[0], 0x00, sizeof(bufMsg));
1461 if (bufMsg[0] != 0x00) {
1463 memset(&buf[0], 0x00, sizeof(buf));
1464 snprintf(reinterpret_cast<char *>(&buf[0]), sizeof(buf),
1468 memcpy(pBuf, &buf[0], sizeof(buf));
1477 * Message Control Table Usage Counter Increment
1481 static void MsgIncUseCntOfCtrlTbl(void) {
1482 g_msg_ctrl_tbl.use_cnt++;
1488 * Message control table usage counter decrement
1492 static void MsgDecUseCntOfCtrlTbl(void) { // LCOV_EXCL_START 8:dead code
1493 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1494 g_msg_ctrl_tbl.use_cnt--;
1501 * Message Control Table Reserved Counter Increment
1505 static void MsgIncRsvCntOfCtrlTbl(void) {
1506 g_msg_ctrl_tbl.rsv_cnt++;
1512 * Message Control Table Reserved Counter Decrement
1516 static void MsgDecRsvCntOfCtrlTbl(void) {
1517 g_msg_ctrl_tbl.rsv_cnt--;
1523 * Resource Acquisition Decision(Message control table)
1528 * @retval TRUE : Normal
1529 * @retval FALSE : Anomaly (Resource shortage)
1531 BOOL _pb_GetMsgResource(void) {
1537 /* Increment Message Control Table Reservation Counter */
1538 MsgIncRsvCntOfCtrlTbl();
1540 cnt = g_msg_ctrl_tbl.use_cnt + g_msg_ctrl_tbl.rsv_cnt;
1541 if (cnt >= FULL_MSG_NUM_CTRL_MSGQUE) {
1543 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Lack of resources " \
1544 "[FATAL][use_cnt:%d rsv_cnt:%d]", g_msg_ctrl_tbl.use_cnt, g_msg_ctrl_tbl.rsv_cnt);
1545 } else if (cnt >= WARN_MSG_NUM_CTRL_MSGQUE) {
1546 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Lack of resources " \
1547 "[WARN][use_cnt:%d rsv_cnt:%d]", g_msg_ctrl_tbl.use_cnt, g_msg_ctrl_tbl.rsv_cnt);
1557 * Resource release(Message control table)
1563 void _pb_ReleaseMsgResource(void) {
1566 /* Decrement Message Control Table Reservation Counter */
1567 MsgDecRsvCntOfCtrlTbl();