Developer World
Spresense SDK Library v3.2.0-ebc0364
Collaboration diagram for Functions:

Functions

int mpmq_init (mpmq_t *mq, key_t key, cpuid_t cpuid)
 
int mpmq_destroy (mpmq_t *mq)
 
int mpmq_send (mpmq_t *mq, int8_t msgid, uint32_t data)
 
int mpmq_timedsend (mpmq_t *mq, int8_t msgid, uint32_t data, uint32_t ms)
 
int mpmq_trysend (mpmq_t *mq, int8_t msgid, uint32_t data)
 
int mpmq_receive (mpmq_t *mq, uint32_t *data)
 
int mpmq_timedreceive (mpmq_t *mq, uint32_t *data, uint32_t ms)
 
int mpmq_tryreceive (mpmq_t *mq, uint32_t *data)
 
int mpmq_notify (mpmq_t *mq, int signo, void *sigdata)
 

Detailed Description

Function Documentation

◆ mpmq_init()

int mpmq_init ( mpmq_t mq,
key_t  key,
cpuid_t  cpuid 
)

Initialize MP message queue

mpmq_init() initialize MP message queue object. This function needs raw CPU ID at cpuid. User can use mptask_getcpuid() to get asigned CPU ID.

On the worker side, specify known key to initialize with supervisor. In this case, cpuid is ignored. If use mpmq for communicate with sub cores, set 0 to key and target CPU ID to cpuid.

Parameters
[in,out]mqMP message queue object
[in]keyUnique object ID
[in]cpuidTarget CPU ID
Returns
On success, mpmq_init() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_destroy()

int mpmq_destroy ( mpmq_t mq)

Destroy MP message queue

Parameters
[in,out]mqMP message queue object
Returns
On success, mpmq_destroy() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_send()

int mpmq_send ( mpmq_t mq,
int8_t  msgid,
uint32_t  data 
)

Send message via MP message queue

Parameters
[in,out]mqMP message queue object
[in]msgidUser defined message ID (0-127)
[in]dataMessage data
Returns
On success, mpmq_send() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_timedsend()

int mpmq_timedsend ( mpmq_t mq,
int8_t  msgid,
uint32_t  data,
uint32_t  ms 
)

Send message via MP message queue with timeout

Parameters
[in,out]mqMP message queue object
[in]msgidUser defined message ID (0-127)
[in]dataMessage data
[in]msTime out (milliseconds). This parameter is unused.
Returns
On success, mpmq_timedsend() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_trysend()

int mpmq_trysend ( mpmq_t mq,
int8_t  msgid,
uint32_t  data 
)

Try send message via MP message queue

Parameters
[in,out]mqMP message queue object
[in]msgidUser defined message ID (0-127)
[in]dataMessage data
Returns
On success, mpmq_trysend() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_receive()

int mpmq_receive ( mpmq_t mq,
uint32_t *  data 
)

Receive message via MP message queue

Parameters
[in,out]mqMP message queue object
[out]dataMessage data
Returns
On success, mpmq_receive() returns message ID. On error, it returns an error number.
Return values
-EINVALInvalid argument

◆ mpmq_timedreceive()

int mpmq_timedreceive ( mpmq_t mq,
uint32_t *  data,
uint32_t  ms 
)

Receive message via MP message queue with timeout

Parameters
[in,out]mqMP message queue object
[out]dataMessage data
[in]msTime out (milliseconds). If ms is zero, then it waits forever until receiving message. If ms is MPMQ_NONBLOCK, then it behaves as polling without blocking.
Returns
On success, mpmq_timedreceive() returns message ID. On error, it returns an error number.
Return values
-EINVALInvalid argument
-ETIMEDOUTTimed out
-EAGAINTry again when data hasn't come with non-blocking mode

◆ mpmq_tryreceive()

int mpmq_tryreceive ( mpmq_t mq,
uint32_t *  data 
)

Try receive message via MP message queue

Parameters
[in,out]mqMP message queue object
[out]dataMessage data
Returns
On success, mpmq_tryreceive() returns message ID. On error, it returns an error number.
Return values
-EINVALInvalid argument
-EAGAINTry again when data hasn't come

◆ mpmq_notify()

int mpmq_notify ( mpmq_t mq,
int  signo,
void *  sigdata 
)

Request signal when MP message arrival

Parameters
[in,out]mqMP message queue object
[in]signoSignal number
[in]sigdataSignal data
Returns
On success, mpmq_notify() returns 0. On error, it returns an error number.
Return values
-EINVALInvalid argument