private void bCardInfo_Click(object sender, EventArgs e)
        {
            tCardInfo.Clear();
            byte bCardType = 0;

            byte[] bCardUID = new byte[9];
            byte   bUidSize = 0;
            String sBuffer  = null;

            log_name = "";

            unsafe
            {
                card_info = "";

                fixed(byte *uid = bCardUID)
                status = uFCoder.GetCardIdEx(&bCardType, uid, &bUidSize);

                status = uFCoder.GetDlogicCardType(&bCardType);
                if (status != 0)
                {
                    tInfo.Text = "Error has occured, Error code: " + "0x" + status.ToString("X2");
                }



                for (byte bCounter = 0; bCounter < bUidSize; bCounter++)
                {
                    sBuffer += bCardUID[bCounter].ToString("X2");
                }

                card_info += "Card type: " + "0x" + bCardType.ToString("X2") + " - " + GetDlTypeName(bCardType) + "\n";

                card_info += "Card UID: " + sBuffer + " --- UID Length: " + bUidSize + " Bytes\n";

                card_info += MaxBlocks(bCardType) + " blocks," + BytesPerBlock(bCardType) + " bytes per block, total " + MaxBytes(bCardType) + " Bytes\n";

                tCardInfo.Text = card_info;

                log_name += sBuffer;

                if (bCardType != GlobalCardType)
                {
                    GlobalCardType = bCardType;
                }
            }

            if (MaxBlocks(bCardType) == 0)
            {
                bReadCard.Enabled = false;
            }
            else
            {
                bReadCard.Enabled = true;
            }
        }
Exemplo n.º 2
0
        private void prn_status(DL_STATUS status, string ok_text)
        {
            string msg;
            string status_msg = status.ToString().Replace("UFR_", "").Replace('_', ' ');

            // remove from start UFR_
            // all _ to space

            if (status == DL_STATUS.UFR_OK)
            {
                msg = " OK - " + ok_text;
                statusResult.BackColor = Color.Lime;
            }
            else
            {
                //msg = " Error: " + status_msg;
                msg = " " + status_msg;

                statusResult.BackColor = Color.Red;
            }

            // prn
            statusResult.Text = msg;
        }
Exemplo n.º 3
0
 public string getLastError()
 {
     return(status.ToString());
 }
Exemplo n.º 4
0
 void SetStatusBar(DL_STATUS result, System.Windows.Forms.StatusStrip stbStatusBar)
 {
     stbStatusBar.Items[1].Text = "0x" + result.ToString("X2");
     stbStatusBar.Items[2].Text = ERROR_CODES[result];
 }
        private void bReadCard_Click(object sender, EventArgs e)
        {
            tInfo.Clear();
            ASCIIBox.Clear();

            byte bDLCardType;

            unsafe
            {
                uFCoder.GetDlogicCardType(&bDLCardType);
            }

            int uiDataLength = MaxBytes(bDLCardType);

            byte[]    baReadData      = new byte[uiDataLength];
            byte[]    DataOut         = new byte[uiDataLength];
            ushort    uiLinearAddress = 0;
            int       uiBytesRet      = 0;
            DL_STATUS status;

            var time = DateTime.Now;

            formattedTime = time.ToString("HH:mm:ss yyyy-MM-dd");

            unsafe
            {
                byte[] KeyPK = new byte[6] {
                    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
                };

                fixed(byte *PData = baReadData)
                {
                    fixed(byte *ptr_key = KeyPK)
                    status = uFCoder.LinRowRead_PK(PData, uiLinearAddress, (ushort)uiDataLength, (ushort *)&uiBytesRet, MIFARE_AUTHENT1A, ptr_key);
                }

                if (status == DL_OK)
                {
                    tInfo.Text = "Info generated on: " + formattedTime + "\n" + card_info;

                    tInfo.AppendText("\r\n" + "Dec  Hex   Bytes                                            " + "\r\n");

                    ASCIIBox.AppendText("\r\nDec  Hex\r\n");

                    string ascii_string = "";

                    for (int i = 0; i < baReadData.Length; i++)
                    {
                        string data = "";
                        string line = "";

                        DataOut[i] = baReadData[i];

                        if (i == 0)
                        {
                            tInfo.AppendText("00   000   ");
                        }
                        else if (i != 0 && i % 16 == 0)
                        {
                            line  = "";
                            line += "\r\n" + (i / 16).ToString("D2") + "   " + (i / 16).ToString("X3") + "   ";
                            tInfo.AppendText(line);
                        }

                        data += baReadData[i].ToString("X2") + " ";

                        tInfo.Text += data;
                        if (baReadData[i] < 20 || baReadData[i] > 128)
                        {
                            ascii_string += ".";
                        }
                        else
                        {
                            ascii_string += (char)baReadData[i];
                        }
                    }

                    for (int k = 0; k < baReadData.Length; k++)
                    {
                        string line = "";

                        if ((k != 0) && (k % 16 == 0))
                        {
                            ASCIIBox.Text += "\r\n";
                            line           = "";
                            line          += "\r\n" + (k / 16).ToString("D2") + "   " + (k / 16).ToString("X3") + "   ";
                            ASCIIBox.AppendText(line);
                        }
                        if (k == 0)
                        {
                            ASCIIBox.AppendText("00   000   ");
                        }

                        ASCIIBox.Text += ascii_string[k];
                    }

                    uFCoder.ReaderUISignal(1, 1);
                }
                else
                {
                    uFCoder.ReaderUISignal(1, 0);

                    tInfo.Text = card_info;

                    tInfo.AppendText("\n An error has occured, Error code: " + "0x" + status.ToString("X2"));
                }



                var    time_log = DateTime.Now;
                string format_time;
                format_time = time.ToString("HH-mm-ss yyyy-MM-dd");

                log_name = log_name + "_" + format_time;

                if (saveMFD.Checked)
                {
                    log_name = log_name + ".mfd";

                    File.WriteAllText(log_name, Encoding.ASCII.GetString(DataOut));

                    log_name = log_name.Remove(log_name.Length - 4);
                }
                if (saveTXT.Checked)
                {
                    log_name = log_name + ".txt";
                    File.WriteAllText(log_name, "\r\n--------------------------HEX----------------------------\r\n" +
                                      tInfo.Text + "\r\n--------------------------ASCII----------------------------\r\n" + ASCIIBox.Text);

                    log_name = log_name.Substring(log_name.Length - 4);
                }

                log_name = "";

                bReadCard.Enabled = false;
            }
        }