Skip to main content
Visitor II
July 5, 2022
Solved

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

  • July 5, 2022
  • 3 replies
  • 2877 views

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 topic has been closed for replies.
    Best answer by Brian TIDAL

    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

    3 replies

    Technical Moderator
    July 5, 2022

    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

    Visitor II
    July 5, 2022

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

    Technical Moderator
    July 5, 2022

    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

    Technical Moderator
    July 5, 2022

    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

    Visitor II
    July 5, 2022

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

    Technical Moderator
    July 5, 2022

    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

    Visitor II
    July 5, 2022

    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 ?