×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Unhappy Writing and Reading to an external mifare4k card

    I am a newbie when it comes to using NFC related APIs .

    I am trying to write data to an external mifare4k card and then read the contents from the card using a Nokia 6131 NFC mobile phone.

    However even when there is no error being thrown , I am not being able to retrieve teh data written or I do no t know if the data is written.
    Please help me how can I debug this when connected to the phone , I heard we can do this using putty.exe, but am not aware how to do this.

    Moreover a simple example to do this would be helpful..

  2. #2
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Writing and Reading to an external mifare4k card

    Hallo,

    Quote Originally Posted by dushdushyant View Post
    However even when there is no error being thrown , I am not being able to retrieve teh data written or I do no t know if the data is written.
    There is a recent thread on reading and writing MIFARE Classic with the Nokia NFC API.

    Quote Originally Posted by dushdushyant View Post
    Please help me how can I debug this when connected to the phone
    Actually, I'm not aware of any method to directly debug applications on the phone. I would suggest you debug using the emulator. The emulator from the Nokia 6212 SDK is particularly helpful when it comes to tesing with real tags: You can connect an Omnikey or Pegoda reader to simulate a real RF interface. Also that emulator's NFC Manager application provides a way to read the data from tags (also MIFARE Classic) and display it in a HEX editor.

    br,
    Michael

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Red face Re: Writing and Reading to an external mifare4k card

    Hi,

    I found out a way of debugging on the device,
    Nokia NFC6131 seems to support putty for debugging and all the sysout is coming onto the screen

    next:
    I found the error,

    Neither write nor read operation is being done

    i am getting the following error: com.nokia. nfc.nxp.mfstd.MFStandardException: Write failed

    now what does this mean

  4. #4
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Writing and Reading to an external mifare4k card

    Hallo,

    Quote Originally Posted by dushdushyant View Post
    i am getting the following error: com.nokia.nfc.nxp.mfstd.MFStandardException: Write failed

    now what does this mean
    This exception means that the write operation failed ;-) Use the exception's getReason() method to get a more detailed error code.

    br,
    Michael

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Re: Writing and Reading to an external mifare4k card

    Hi Michael,

    Thanks for the help.

    I tried numerous ways

    First I used

    MFBlock block6 = cardConnection.getBlock(6);
    block6.write(key, data, 0, 0, data.length);

    This gave me error with illegal argumnent exception

    Then after several attempts I used
    block6.write(key, data,0);

    now this is giving MFStandardException with getReason as 0.

  6. #6
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Writing and Reading to an external mifare4k card

    Hallo,

    Quote Originally Posted by dushdushyant View Post
    block6.write(key, data, 0, 0, data.length);

    This gave me error with illegal argumnent exception
    Right, your parameter order is wrong! Check the documentation for the write() method.

    Quote Originally Posted by dushdushyant View Post
    Then after several attempts I used
    block6.write(key, data,0);

    now this is giving MFStandardException with getReason as 0.
    I hadn't expected this error. I expected a reason of 1, which would have meant that you used an invalid authentication key.

    br,
    Michael

  7. #7
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Re: Writing and Reading to an external mifare4k card

    Hi,


    Thanks for clearing some doubts ,
    When I use a key I am getting error code of 1,
    So i tried writing without a key

    i used block6.write(null, data, 0);

    where data is in byte[] .

    This is allowing me to write,
    However, the joy of write is short lived because it seems to be corrupting the sector and after the first write I am not being able to over write nor erase or read from that written block

    Where am i going wrong.

    I am getting something like

    Error code 0
    com.nokia.nfc.nxp.mfstd.MFStandardException: Write failed

    Error code 0
    com.nokia.nfc.nxp.mfstd.MFStandardException: Read failed

  8. #8
    Registered User
    Join Date
    Oct 2009
    Posts
    15

    Re: Writing and Reading to an external mifare4k card

    Thanks Michael,

    Yippee now its done,

    Thanks for sharing the url for those mifare documentations.

    The problem that I was facing was that I was trying to write on the Sector trailer blocks too.
    http://discussion.forum.nokia.com/fo...milies/mad.gif



    Now i can read, write , and clear the data on teh mifare 4K card

    Thanks cheers
    http://discussion.forum.nokia.com/fo...ies/tongue.gif

Similar Threads

  1. Writing to and reading from an external Mifare 1k tag
    By savio_mf in forum Near Field Communication
    Replies: 1
    Last Post: 2008-03-15, 11:36
  2. Replies: 4
    Last Post: 2008-03-10, 02:23
  3. Help!! Reading and writing to cards from the 6131 and from a card reader
    By wobbly101 in forum Near Field Communication
    Replies: 1
    Last Post: 2008-02-23, 21:08
  4. Reading and writing to the Secure Element (Nokia 6131)
    By wobbly101 in forum Near Field Communication
    Replies: 0
    Last Post: 2007-11-09, 13:43
  5. 6131 fails writing business card into Type 4 Tag
    By ustagnu in forum Near Field Communication
    Replies: 0
    Last Post: 2007-08-31, 14:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×