Dear all,

I need help on programming Mifare cards.

I want to be able to read and write to a 1k mifare card. I bought a ACR1281U dual reader and also have some documentation but have not understand how to read data and write data to Mifare cards.

I did appreciate your support on this, should anybody be able to do this.

Thank you.

Recommended Answers

All 8 Replies

usually a product like this comes with a software disc or you can download it from their website..if thats not the case, is there any part in that documentation that talks about developing or programing if so, upload it or send a url.
anyway this is how you read the data

  • connect it to your pc
  • add a SerialPort control to your VB form and a Combobox
  • get the name of the ports that are connected to your pc

    ComboBox1.Items.AddRange(IO.Ports.SerialPort.GetPortNames)

  • assign your devise to the serialport

    SerialPort1.PortName = ComboBox1.SelectedItem.ToString

  • open it

    SerialPort1.Open()

  • Receive data as bytes and convert to plain text

    Private Sub DataReceived(ByVal sender As Object, _
    ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
    Handles SerialPort1.DataReceived
    If SerialPort1.BytesToRead > 0 Then
    SerialPort1.Read(your data "bytes")
    end if
    'convert bytes to plain text
    System.Text.Encoding.ASCII.GetString(your data)

good luck

Thank you Oussama,

Attached is code snippet I have from them, perhaps it can be a pointer to provide me assitance.

That's it, copy the code and paste it in your vb project and you should add a reference to this "ModWinsCard64.SCARD".
now pay attention to this code

    Private Sub InitMenu()

        connActive = False
        cbReader.Items.Clear()
        cbReader.Text = ""
        mMsg.Items.Clear()
        displayOut(0, 0, "Program ready")
        bConnect.Enabled = False
        bInit.Enabled = True
        bReset.Enabled = False
        rbNonVolMem.Checked = False
        rbSource2.Checked = True
        rbVolMem.Checked = True
        tMemAdd.Text = ""
        tKey1.Text = ""
        tKey2.Text = ""
        tKey3.Text = ""
        tKey4.Text = ""
        tKey5.Text = ""
        tKey6.Text = ""
        gbLoadKeys.Enabled = False
        tBlkNo.Text = ""
        tKeyAdd.Text = ""
        gbAuth.Enabled = False
        tBinBlk.Text = ""
        tBinLen.Text = ""
        tBinData.Text = ""
        gbBinOps.Enabled = False
        tValAmt.Text = ""
        tValBlk.Text = ""
        tValSrc.Text = ""
        tValTar.Text = ""
        gbValBlk.Enabled = False

    End Sub

you need to add these controls to your form like "bConnect.Enabled = False" you need to add a button and name it bConnect and for this "tKey1.Text" add a textbox named tKey1 and for "mMsg.Items.Clear()" add a listbox mMsg etc..when you finish run your program and press connect and test your device..
with this code you can connect and display data, clear them and print them (side note: a Buffer is what holds your data to read them).
good luck

I did not understand your advice, please can you make it more simpler.

Thank you.

try the code in the file "MifareCardProg_1.txt" if you get any errors post it here

Thank you Oussama,

okay, which part of the script handle writing and reading from mifare card. that is just the challenge I have.

And perhaps if you have another code that you have used and work fine I did appreciate you send it to me.

hi...

I also have the same problem where I could not read 1k Mifare tag . I use the reader cr038 from here http://www.cytron.com.my/viewProduct.php?pcode=RFID-ICRW-CR038&name=Mifare%20Reader/Writer%20CR038 ...
I also tried the coding as above but still fail to read it.. and based on the datasheet(user manual) given the command to be used in hexadecimal .. can anyone help me how to do it?

Your help is greatly appreciated ... thank you

*This is one of the command given *

Initialize Port: 0x0101
Function: Set Baud Rate of CR038’s UART
Packet Format (Hexadecimal): AA BB 06 00 00 00 01 01 Baud XOR
AA BB = Header, 2 bytes.
06 00 = Packet length, 2 bytes, lower byte first. This indicate there are 6 bytes of data from Node
ID to XOR.
00 00 = Node ID, Serial number of CR038, 2 bytes, lower byte first. 00 00 mean broadcast, it
works for any ID.
01 01 = Function/Command Code for Initialize Port, 2 bytes, lower byte first.
Baud = Parameter for Baud rate. 1 byte.
● 0 = 4800 bps
● 1 = 9600 bps
● 2 = 14400 bps
● 3 = 19200 bps
● 4 = 28800 bps
● 5 = 38400 bps
● 6 = 57600 bps
● 7 = 115200 bps
XOR = result of exclusive OR operation from Node ID to Baud, in this example.
Example: To set the UART Baud rate to 19200. You will need to send command in the current
baud rate, not the desire baud rate. This is the command from host to CR038:
Command (Hexadecimal): AA BB 06 00 00 00 01 01 03 03
Reply from CR038 (Hexadecimal): AA BB 06 00 BF FF 01 01 00 40
BF FF = Node ID or Serial number of CR038, 2 bytes, lower byte 1st.
01 01 = Function/Command Code from host, 2 bytes, lower byte 1st.
00 = Status, 1 byte. 0 mean success, other than 0 mean fail.
40 = Result of XOR operation from Node ID to Status. Try it and you will get 0x40

Set Antenna Status: 0x010C
Function: Set Antenna status on CR038, needed to access (read or write) to Mifare card.
Packet Format (Hexadecimal): AA BB 06 00 00 00 0C 01 Antenna XOR
AA BB = Header, 2 bytes.
06 00 = Packet length, 2 bytes, lower byte first. This indicate there are 6 bytes of data from Node
ID to XOR.
00 00 = Node ID, Serial number of CR038, 2 bytes, lower byte first. 00 00 mean broadcast, it
works for any ID.
0C 01 = Function/Command Code for Set Antenna Status, 2 bytes, lower byte first.
Antenna = Parameter for Antenna status. 1 byte.
● 0 = Antenna OFF
● 1 = Antenna ON
XOR = result of exclusive OR operation from Node ID to Antenna, in this example.
Example: To ON (Activate) Antenna on CR038 (default is OFF). This is the command from host to
CR038:
Command (Hexadecimal): AA BB 06 00 00 00 0C 01 01 0C
Reply from CR038 (Hexadecimal): AA BB 06 00 BF FF 0C 01 00 4D
BF FF = Node ID or Serial number of CR038, 2 bytes, lower byte 1st. It can be any value.
0C 01 = Function/Command Code from host, 2 bytes, lower byte 1st.
00 = Status, 1 byte. 0 mean success, other than 0 mean fail.
4D = Result of XOR operation from Node ID to Status.
The Antenna on CR038 will be activated and you can further send command to access the Mifare
card.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.