cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid command code error while performing Write operation from C# based PC software application

Nikhil D&K
Senior

Hello,

We currently have a desktop application based on C# for communicating between ST25R3911B-DISCO board and ST25DV dynamic tag. The application itself is similar to ST PC software for ST25R3911B-DISCO board but with limited functionalities as currently we only need Fast Transfer Mode for communication.

My PC software based on C# is able to perform inventory discovery successfully, and is also able to read the data from mailbox (verified by writing data to mailbox using ST software and reading data by using C# software). But issue arrives when i try to perform Mailbox write operation, the error returned is invalid command code for write operation. I looked at the ST25DV datasheet for RF commands and frame formats also the logs of the ST PC software to understand how the write operation data frame is transmiited but that's different from the data frame that's sent from my application. There are files in my project which adds the protocol header to data frame.

So can anyone please help me what could be the issue here. I have added the payload that sent from my application to ST25DV dynamic tag for both read and write operation below:

Here is the frame format that's sent for read operation which is working:

    READ:
    --------------------
     
    0F-15-00-44-00-10-04-40-DE-00-0C-22-AC-02-81-38-3F-05-00-25-02-E0-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
      
    1st byte is counter
    AC - read cmd

Here is the frame format that's sent for write operation which is not working and throwing error of invalid cmd:

    WRITE :
     --------------------
    01-18-00-44-00-13-04-40-DE-00-0C-22-AA-02-81-38-3F-05-00-25-02-E0-04-FF-FF-FF-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00     
     
     
    1st byte is counter
    AA - write cmd
    04 - data length 
    FF-FF-FF-FF - data

 NOTES:

In both write and read packets, (4-5)bytes before CMD code is same (i.e "40-DE-00-0C-22") and bytes after CMD code is same (i.e "02-81-38-3F-05-00-25-02-E0")

So can you please let me know what could be the possible reason why i am getting this invalid command error, although my command is right.  

0693W00000QKMmVQAX.png0693W00000QKMmuQAH.png0693W00000QKMmpQAH.png0693W00000QKMmzQAH.png

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions

Hi Nikhil,

if you set MSGLength to 04, this means you want to write 5 bytes so the tag is expecting 5 bytes and you send only FF-FF-FF-FF i.e. 4 bytes.

If you want to send only 4 bytes, the MSGlength has to be 03 and the full RF command should be:

22-AA-02-81-38-3F-05-00-25-02-E0-03-FF-FF-FF-FF

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

16 REPLIES 16
Brian TIDAL
ST Employee

Hi,

the data length is incorrect. "MSGlength parameter of the command is the number of Data bytes minus - 1 (00 for 1 byte of data, FFh for 256 bytes of data)" See § 7.6.31 Write Message and table Table 197. Write Message request format in the ST25DV datasheet.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Okay, will check this out. But as mentioned the error response which was received was of invalid command code.

Ulysses HERNIOSUS
ST Employee

Hi,

more details about inspect the firmware sources: st_stream.h and dispatcher.c the comment before processCmd().

Decoding the write request above:

  • 01- transaction ID
  • 18- length of the request
  • 00- reserved
  • 44- top level command id - always the same.
  • 00-13- length of the bytes following (above 18-5: fits)
  • 04-40- max response length
  • DE- iso15693txrx cmd
  • 00-0C- iso15693txrx timeout value
  • 22- iso15693 request flag
  • AA-02- iso15693 command (ST prop)
  • 81-38-3F-05-00-25-02-E0- UID of the addressed tag.
  • 04- msg length
  • FF-FF-FF-FF message

I don't find anything wrong here. How is the "invalid command error" reported back to you?

BR, Ulysses

Hi Nikhil,

when sending 22-AA-02-81-38-3F-05-00-25-02-E0-04-FF-FF-FF-FF Write message command to the tag, the reply is 01-02 i.e. Command not recognized. As one byte is missing, the command cannot be properly recognized.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

As per previous reply shouldn't the message length be 3 instead of 4 ?

Brian TIDAL
ST Employee

Hi Nikhil,

the frame 01-18-00-44-00-13-04-40-DE-00-0C-22-AA-02-81-38-3F-05-00-25-02-E0-04-FF-FF-FF-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 is the frame exchanged from the PC to the ST25R3911B NFC reader device. This frame conveys the RF payload (22-AA-02-81-38-3F-05-00-25-02-E0-04-FF-FF-FF-FF) that is exchanged between the ST25R3911B NFC reader and the ST25DV tag.

Ulysses explanation is related to the frame exchanged between the PC and the ST25R3911B NFC reader. From PC<->ST25R3911B communication protocol point of view, this frame is correct. Only the RF payload has an incorrect MSGlength value of 04 instead of 03.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello Brian,

Can you tell me which byte is missing than ?

Okay thanks. So if i send the correct data length (in my case 3) most probably it should successfully transmit right ? And if i still get the error, it could be related to something else ?

Hi Nikhil,

if you set MSGLength to 04, this means you want to write 5 bytes so the tag is expecting 5 bytes and you send only FF-FF-FF-FF i.e. 4 bytes.

If you want to send only 4 bytes, the MSGlength has to be 03 and the full RF command should be:

22-AA-02-81-38-3F-05-00-25-02-E0-03-FF-FF-FF-FF

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.