* Send data through an IPC channel, wait for the reply or not. */
| 474 | * Send data through an IPC channel, wait for the reply or not. |
| 475 | */ |
| 476 | static rt_err_t _send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, int need_reply, rt_channel_msg_t data_ret, rt_int32_t time) |
| 477 | { |
| 478 | rt_ipc_msg_t msg; |
| 479 | rt_err_t rc = -RT_ERROR; |
| 480 | |
| 481 | if (need_reply) |
| 482 | { |
| 483 | RT_DEBUG_NOT_IN_INTERRUPT; |
| 484 | } |
| 485 | |
| 486 | if (ch == RT_NULL) |
| 487 | { |
| 488 | rc = -RT_EIO; |
| 489 | } |
| 490 | else |
| 491 | { |
| 492 | if (rt_object_get_type(&ch->parent.parent) != RT_Object_Class_Channel) |
| 493 | { |
| 494 | rc = -RT_EIO; |
| 495 | } |
| 496 | else if (need_reply && time == 0) |
| 497 | { |
| 498 | rc = -RT_ETIMEOUT; |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | /* allocate an IPC message */ |
| 503 | msg = _ipc_msg_alloc(); |
| 504 | if (!msg) |
| 505 | rc = -RT_ENOMEM; |
| 506 | else |
| 507 | rc = _do_send_recv_timeout(ch, data, need_reply, data_ret, time, msg); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | return rc; |
| 512 | } |
| 513 | |
| 514 | static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, int need_reply, rt_channel_msg_t data_ret, rt_int32_t time, rt_ipc_msg_t msg) |
| 515 | { |
no test coverage detected