MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / mq_send

Function mq_send

components/libc/posix/ipc/mqueue.c:235–255  ·  view source on GitHub ↗

* @brief Sends a message to a message queue. * @param id Message queue descriptor. * @param msg_ptr Pointer to the buffer containing the message to be sent. * @param msg_len Size of the message to be sent. * @param msg_prio Priority of the message to be sent. * @return Upon successful completion, returns 0; * otherwise, returns -1 and sets errno to indicate the error. *

Source from the content-addressed store, hash-verified

233 * and the function returns -1.
234 */
235int mq_send(mqd_t id, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
236{
237 rt_mq_t mq;
238 rt_err_t result;
239 struct mqueue_file *mq_file;
240 mq_file = fd_get(id)->vnode->data;
241 mq = (rt_mq_t)mq_file->data;
242
243 if ((mq == RT_NULL) || (msg_ptr == RT_NULL))
244 {
245 rt_set_errno(EINVAL);
246 return -1;
247 }
248 result = rt_mq_send_wait_prio(mq, (void *)msg_ptr, msg_len, msg_prio, 0, RT_UNINTERRUPTIBLE);
249 if (result == RT_EOK)
250 return 0;
251
252 rt_set_errno(EBADF);
253
254 return -1;
255}
256RTM_EXPORT(mq_send);
257
258/**

Callers 3

mq_timedsendFunction · 0.85
send_1Function · 0.85
send_2Function · 0.85

Calls 3

rt_set_errnoFunction · 0.85
rt_mq_send_wait_prioFunction · 0.85
fd_getFunction · 0.50

Tested by

no test coverage detected