cancel
Showing results for 
Search instead for 
Did you mean: 

CMD_FAILED exception about st25Android SDK: readMailboxMessage()

门旭.1
Associate

I can use st25DVTag.writeMailboxMessage(bytes) to write the Mailbox,I can also use st25DVTag.readMailboxMessageLength() to get the length of message(it returns 1),but when I try to read the Mailbox message,it throw a com.st.st25sdk.STException: Error CMD_FAILED.

st25DVTag.readMailboxMessage(0, 0) or st25DVTag.readMailboxMessage(0, 1), both of them can occur exception.How can I read the MailboxMessage?

0693W00000BbLqaQAF.png

1 ACCEPTED SOLUTION

Accepted Solutions
Olivier L
ST Employee

Hi,

After writting some data in the mailbox, you should wait that the MCU writes an answer. Here, I think that you tries to read the Mailbox before that the recipient gets the time to answer. I can see that the read message length is null.

After writing the message please use hasHostPutMsg() to monitor if the MCU has written an answer (take care to set "refresh" parameter to true). When it is the case, you can then read the message length and read the message.

A side comment: You can avoid the call to readMsgLength() . When calling readMailboxMessage() if size = 0 and mbAddress = 0, the command returns ALL bytes available.

I would like to point something else:

I can see that you are using "addressed commands" (this is commands containing the UID of the targeting tag).

This is the recommended way for most Type V commands but not for Mailbox usage. When using the Mailbox, a RF command can happen at the same time as an I2C command (we call it a "collision"). When the collision happens, if you have used an addressed command, you will get a timeout (which can take up to 2 seconds!) and if you have used a non addressed command, you will get an error 01 0F. You can then retry of read the status of the Mailbox (= register REGISTER_DYN_MB_CTRL_ADDRESS) to understand what happen.

To use a non addressed mode:

When calling the Mailbox functions, you can pass an extra parameter called flag:

byte flag = HIGH_DATA_RATE_MODE;

byte[] receivedData = mST25DVTag.readMailboxMessage(0, 0, flag);

Same thing for the other mailbox commands.

Regards

Olivier

View solution in original post

3 REPLIES 3
Olivier L
ST Employee

Hi,

After writting some data in the mailbox, you should wait that the MCU writes an answer. Here, I think that you tries to read the Mailbox before that the recipient gets the time to answer. I can see that the read message length is null.

After writing the message please use hasHostPutMsg() to monitor if the MCU has written an answer (take care to set "refresh" parameter to true). When it is the case, you can then read the message length and read the message.

A side comment: You can avoid the call to readMsgLength() . When calling readMailboxMessage() if size = 0 and mbAddress = 0, the command returns ALL bytes available.

I would like to point something else:

I can see that you are using "addressed commands" (this is commands containing the UID of the targeting tag).

This is the recommended way for most Type V commands but not for Mailbox usage. When using the Mailbox, a RF command can happen at the same time as an I2C command (we call it a "collision"). When the collision happens, if you have used an addressed command, you will get a timeout (which can take up to 2 seconds!) and if you have used a non addressed command, you will get an error 01 0F. You can then retry of read the status of the Mailbox (= register REGISTER_DYN_MB_CTRL_ADDRESS) to understand what happen.

To use a non addressed mode:

When calling the Mailbox functions, you can pass an extra parameter called flag:

byte flag = HIGH_DATA_RATE_MODE;

byte[] receivedData = mST25DVTag.readMailboxMessage(0, 0, flag);

Same thing for the other mailbox commands.

Regards

Olivier

Hello Olivier,

Thanks for your answer very much! I try to use 'byte[] bytes = st25DVTag.readMailboxMessage(0, 0, HIGH_DATA_RATE_MODE);' ,it worked.

Best wishes

Men Xu0693W00000BbUPdQAN.png 

Olivier L
ST Employee

Hi Men Xu,

Good, I'm glad that it works.

Best wishes

Olivier