├── .libs ├── function ├── function.oo ├── listdevs ├── lt-function ├── lt-function.oo └── lt-listdevs ├── Makefile ├── README.md ├── define.h ├── function.c ├── function.h └── test.c /.libs/function: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/function -------------------------------------------------------------------------------- /.libs/function.oo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/function.oo -------------------------------------------------------------------------------- /.libs/listdevs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/listdevs -------------------------------------------------------------------------------- /.libs/lt-function: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/lt-function -------------------------------------------------------------------------------- /.libs/lt-function.oo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/lt-function.oo -------------------------------------------------------------------------------- /.libs/lt-listdevs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simpleyyt/libfunction_so_usb/edecc76183479a42e3eb752da83c1d007722e8f7/.libs/lt-listdevs -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | projectName = libfunction 2 | SourceName = function.c 3 | TargeName = $(projectName).so 4 | 5 | testName=test 6 | testSource=$(testName).c 7 | testTarge=$(testName) 8 | 9 | ifeq ($(CC), ) 10 | CC = gcc 11 | endif 12 | 13 | $(testTarge):$(testSource) $(TargeName) 14 | $(CC) $(testSource) -fPIC -o $(testTarge) ./libfunction.so 15 | 16 | $(TargeName):$(SourceName) $(libusbA) 17 | $(CC) $(SourceName) `pkg-config --cflags --libs libusb-1.0` -fPIC -shared -o $(TargeName) -lpthread -lrt 18 | 19 | clean: 20 | rm -f $(TargeName) 21 | rm -f $(testTarge) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libfunction_so_usb 2 | ================== 3 | 4 | A library for USB RFID card Reader by USB HID 5 | 6 | INSTALL 7 | ======= 8 | 9 | 1. `cd` to the source directory. 10 | 2. Running `make` to compile the package. 11 | 3. A library file `libfunction.so` and a `test` program will be generated. 12 | 13 | For Arm 14 | ======== 15 | 16 | 1. Running the shell: 17 | 18 | export host=arm-linux 19 | export CC=arm-linux-gcc 20 | make 21 | 22 | 2. A library file `libfunction.so` and a `test` program will be generated. 23 | 24 | -------------------------------------------------------------------------------- /define.h: -------------------------------------------------------------------------------- 1 | //ISO14443A 2 | #define REQA 0x03 3 | #define Anticoll_A 0x04 4 | #define Select_A 0x05 5 | #define Halt_A 0x06 6 | 7 | //ISO14443B 8 | #define ReqB 0x09 9 | #define AnticollB 0x0A 10 | #define Attrib_TypeB 0x0B 11 | #define Rst_TypeB 0x0C 12 | #define ISO14443_TypeB_Transfer_Command 0x0D 13 | 14 | //MF 15 | 16 | #define MF_Read 0x20 17 | #define MF_Write 0x21 18 | #define MF_InitVal 0x22 19 | #define MF_Decrement 0x23 20 | #define MF_Increment 0x24 21 | #define MF_GET_SNR 0x25 22 | #define ISO14443_TypeA_Transfer_Command 0x28 23 | 24 | //ISO15693 25 | #define ISO15693_Inventory 0x10 26 | #define ISO15693_Read 0x11 27 | #define ISO15693_Write 0x12 28 | #define ISO15693_Lockblock 0x13 29 | #define ISO15693_StayQuiet 0x14 30 | #define ISO15693_Select 0x15 31 | #define ISO15693_Resetready 0x16 32 | #define ISO15693_Write_Afi 0x17 33 | #define ISO15693_Lock_Afi 0x18 34 | #define ISO15693_Write_Dsfid 0x19 35 | #define ISO15693_Lock_Dsfid 0x1A 36 | #define ISO15693_Get_Information 0x1B 37 | #define ISO15693_Get_Multiple_Block_Security 0x1C 38 | #define ISO15693_Transfer_Command 0x1D 39 | 40 | //ultralight 41 | #define CMD_UL_HLRead 0xE0 42 | #define CMD_UL_HLWrite 0xE1 43 | #define CMD_UL_Request 0xE3 44 | 45 | //system setting 46 | #define SetAddress 0x80 47 | #define SetBaudrate 0x81 48 | #define SetSerlNum 0x82 49 | #define GetSerlNum 0x83 50 | #define Write_UserInfo 0x84 51 | #define Read_UserInfo 0x85 52 | #define Get_VersionNum 0x86 53 | #define Control_Led1 0x87 54 | #define Control_Led2 0x88 55 | #define Control_Buzzer 0x89 56 | 57 | #define STX 0xAA 58 | #define ETX 0xBB 59 | 60 | #define PID 0xffff 61 | #define VID 0x0035 62 | -------------------------------------------------------------------------------- /function.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "function.h" 11 | #include "define.h" 12 | #define DATALEN 0x100 13 | #define FALSE -1 14 | #define TRUE 0 15 | 16 | unsigned char Data[DATALEN] = {1}; 17 | unsigned char *Buffer = &Data[8]; 18 | int p = 1; 19 | libusb_device_handle *devs; 20 | 21 | void closeCom(void) 22 | { 23 | int result; 24 | 25 | if (devs == 0) 26 | return; 27 | 28 | result = libusb_release_interface (devs, 0); 29 | if (result != 0) 30 | { 31 | fprintf (stderr, "libusb release interface failed\n"); 32 | } 33 | 34 | libusb_close(devs); 35 | libusb_exit(NULL); 36 | 37 | devs = 0; 38 | } 39 | 40 | int openCom(void) 41 | { 42 | int result; 43 | 44 | if (devs != 0) 45 | return TRUE; 46 | 47 | result = libusb_init(NULL); 48 | if (result < 0) 49 | { 50 | fprintf(stderr, "libusb init error!\n"); 51 | return FALSE; 52 | } 53 | 54 | devs = libusb_open_device_with_vid_pid(NULL, PID, VID); 55 | if( devs==NULL ) 56 | { 57 | fprintf(stderr, "libusb open failed!\n"); 58 | return FALSE; 59 | } 60 | 61 | result = libusb_reset_device(devs); 62 | if (result != 0) 63 | { 64 | fprintf(stderr, "libusb reset failed!\n"); 65 | closeCom(); 66 | return FALSE; 67 | } 68 | 69 | result = libusb_set_configuration (devs, 1); 70 | if (result != 0) 71 | { 72 | fprintf (stderr, "libusb set configuration failed\n"); 73 | closeCom(); 74 | return FALSE; 75 | } 76 | 77 | result = libusb_claim_interface (devs, 0); 78 | if (result != 0) 79 | { 80 | fprintf (stderr, "libusb claim interface failed\n"); 81 | closeCom(); 82 | return FALSE; 83 | } 84 | 85 | return TRUE; 86 | } 87 | 88 | void copyData(unsigned char *s, int spos, unsigned char *d, int dpos, int len) 89 | { 90 | int i; 91 | for (i=0;i 9? (num_blk*16+4):9; 394 | unsigned char DATA[num]; 395 | DATA[0] = mode; 396 | DATA[1] = num_blk; 397 | DATA[2] = blk_add; 398 | copyData(snr,0,DATA,3,6); 399 | int result = sendCommand(MF_Read,DATA,9,DATA,&Statue); 400 | if (result != 0) 401 | return result; 402 | copyData(DATA,0,snr,0,4); 403 | copyData(DATA,4,buffer,0,num_blk*16); 404 | return Statue; 405 | } 406 | 407 | int API_PCDWrite(unsigned char mode, unsigned char blk_add, unsigned char num_blk, unsigned char *snr, unsigned char *buffer) 408 | { 409 | int Statue; 410 | const int num = num_blk * 16 + 9; 411 | unsigned char DATA[num]; 412 | DATA[0] = mode; 413 | DATA[1] = num_blk; 414 | DATA[2] = blk_add; 415 | copyData(snr,0,DATA,3,6); 416 | copyData(buffer,0,DATA,9,num - 9); 417 | int result = sendCommand(MF_Write,DATA,num,DATA,&Statue); 418 | if (result != 0) 419 | return result; 420 | copyData(DATA,0,snr,0,4); 421 | return Statue; 422 | } 423 | 424 | int API_PCDInitVal(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value) 425 | { 426 | int Statue; 427 | unsigned char DATA[12]; 428 | DATA[0] = mode; 429 | DATA[1] = SectNum; 430 | copyData(snr,0,DATA,2,6); 431 | copyData(value,0,DATA,8,4); 432 | int result = sendCommand(MF_InitVal,DATA,12,DATA,&Statue); 433 | if (result != 0) 434 | return result; 435 | copyData(DATA,0,snr,0,4); 436 | return Statue; 437 | } 438 | 439 | 440 | 441 | int API_PCDDec(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value) 442 | { 443 | int Statue; 444 | unsigned char DATA[12]; 445 | DATA[0] = mode; 446 | DATA[1] = SectNum; 447 | copyData(snr,0,DATA,2,6); 448 | copyData(value,0,DATA,8,4); 449 | int result = sendCommand(MF_Decrement,DATA,12,DATA,&Statue); 450 | if (result != 0) 451 | return result; 452 | copyData(DATA,0,snr,0,4); 453 | copyData(DATA,4,value,0,4); 454 | return Statue; 455 | } 456 | 457 | int API_PCDInc(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value) 458 | { 459 | int Statue; 460 | unsigned char DATA[12]; 461 | DATA[0] = mode; 462 | DATA[1] = SectNum; 463 | copyData(snr,0,DATA,2,6); 464 | copyData(value,0,DATA,8,4); 465 | int result = sendCommand(MF_Increment,DATA,12,DATA,&Statue); 466 | if (result != 0) 467 | return result; 468 | copyData(DATA,0,snr,0,4); 469 | copyData(DATA,4,value,0,4); 470 | return Statue; 471 | } 472 | 473 | int GET_SNR(unsigned char mode, unsigned char API_halt, unsigned char *snr, unsigned char*value) 474 | { 475 | int Statue; 476 | unsigned char DATA[5]; 477 | DATA[0] = mode; 478 | DATA[1] = API_halt; 479 | int result = sendCommand(MF_GET_SNR,DATA,2,DATA,&Statue); 480 | if (result != 0) 481 | return result; 482 | snr[0] = DATA[0]; 483 | copyData(DATA,1,value,0,4); 484 | return Statue; 485 | } 486 | 487 | 488 | int MF_Restore(unsigned char mode, int cardlength, unsigned char*carddata ) 489 | { 490 | int Statue; 491 | const int num = cardlength+2; 492 | unsigned char DATA[num]; 493 | DATA[0] = mode; 494 | DATA[1] = cardlength; 495 | copyData(carddata, 0, DATA, 2, cardlength); 496 | int result = sendCommand(ISO14443_TypeA_Transfer_Command,DATA,num,carddata,&Statue); 497 | if (result != 0) 498 | return result; 499 | return Statue; 500 | } 501 | 502 | 503 | int RequestType_B(unsigned char *buffer) 504 | { 505 | int Statue; 506 | int result = sendCommand(ReqB,NULL,0,buffer,&Statue); 507 | if (result != 0) 508 | return result; 509 | return Statue; 510 | } 511 | 512 | 513 | int AntiType_B(unsigned char *buffer) 514 | { 515 | int Statue; 516 | int result = sendCommand(AnticollB,NULL,0,buffer,&Statue); 517 | if (result != 0) 518 | return result; 519 | return Statue; 520 | } 521 | 522 | 523 | int SelectType_B(unsigned char*SerialNum) 524 | { 525 | int Statue; 526 | int result = sendCommand(Attrib_TypeB,SerialNum,4,SerialNum,&Statue); 527 | if (result != 0) 528 | return result; 529 | return Statue; 530 | } 531 | 532 | 533 | int Request_AB(unsigned char* buffer) 534 | { 535 | int Statue; 536 | int result = sendCommand(Rst_TypeB,buffer,4,buffer,&Statue); 537 | if (result != 0) 538 | return result; 539 | return Statue; 540 | } 541 | 542 | 543 | int API_ISO14443TypeBTransCOSCmd(unsigned char *cmd, int cmdSize, unsigned char *buffer) 544 | { 545 | int Statue; 546 | unsigned char DATA[256]; 547 | DATA[0] = cmdSize; 548 | copyData(buffer, 0, DATA, 1 ,cmdSize); 549 | int result = sendCommand(ISO14443_TypeB_Transfer_Command,buffer,cmdSize+1,buffer,&Statue); 550 | if (result != 0) 551 | return result; 552 | return Statue; 553 | } 554 | 555 | 556 | int API_ISO15693_Inventory(unsigned char flag, unsigned char afi, unsigned char *pData, unsigned char *nrOfCard, unsigned char *pBuffer) 557 | { 558 | int Statue; 559 | unsigned char DATA[256]; 560 | DATA[0] = flag; 561 | DATA[1] = afi; 562 | DATA[2] = 0; 563 | copyData(pData, 0, DATA, 3 ,8); 564 | int result = sendCommand(ISO14443_TypeB_Transfer_Command,DATA,11,DATA,&Statue); 565 | if (result != 0) 566 | return result; 567 | *nrOfCard = DATA[0]; 568 | copyData(DATA,1,pBuffer,0,8*DATA[0]); 569 | return Statue; 570 | } 571 | 572 | 573 | int API_ISO15693Read(unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *buffer) 574 | { 575 | int Statue; 576 | int num; 577 | unsigned char DATA[11]; 578 | DATA[0] = flags; 579 | DATA[1] = blk_add; 580 | DATA[2] = num_blk; 581 | num = 3; 582 | if (flags == 0x22) 583 | { 584 | copyData(uid, 0, DATA, 3 ,8); 585 | num = 11; 586 | } 587 | int result = sendCommand(ISO15693_Read,DATA,num,buffer,&Statue); 588 | if (result != 0) 589 | return result; 590 | return Statue; 591 | } 592 | 593 | 594 | int API_ISO15693Write(unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *data) 595 | { 596 | int Statue; 597 | int num, k; 598 | unsigned char DATA[256]; 599 | k = 4; 600 | DATA[0] = flags; 601 | DATA[1] = blk_add; 602 | DATA[2] = num_blk; 603 | num = num_blk*k + 3; 604 | if (flags == 0x22) 605 | { 606 | copyData(uid, 0, DATA, 3 ,8); 607 | num = num_blk*k + 11; 608 | } 609 | copyData(data,0,DATA,3,num_blk*4); 610 | int result = sendCommand(ISO15693_Write,DATA,num,data,&Statue); 611 | if (result != 0) 612 | return result; 613 | return Statue; 614 | } 615 | 616 | 617 | int API_ISO15693Lock(unsigned char flags, unsigned char num_blk, unsigned char *uid, unsigned char *buffer) 618 | { 619 | int Statue; 620 | int num; 621 | unsigned char DATA[10]; 622 | DATA[0] = flags; 623 | DATA[1] = num_blk; 624 | num = 2; 625 | if (flags == 0x22) 626 | { 627 | copyData(uid, 0, DATA, 2 ,8); 628 | num = 10; 629 | } 630 | int result = sendCommand(ISO15693_Lockblock,DATA,num,buffer,&Statue); 631 | if (result != 0) 632 | return result; 633 | return Statue; 634 | } 635 | 636 | 637 | int API_ISO15693StayQuiet(unsigned char flags, unsigned char *uid, unsigned char *buffer) 638 | { 639 | int Statue; 640 | unsigned char DATA[9]; 641 | DATA[0] = flags; 642 | copyData(uid, 0, DATA, 1 ,8); 643 | int result = sendCommand(ISO15693_StayQuiet,DATA,9,buffer,&Statue); 644 | if (result != 0) 645 | return result; 646 | return Statue; 647 | } 648 | 649 | 650 | int API_ISO15693Select(unsigned char flags, unsigned char *uid, unsigned char *buffer) 651 | { 652 | int Statue; 653 | unsigned char DATA[9]; 654 | DATA[0] = flags; 655 | copyData(uid, 0, DATA, 1 ,8); 656 | int result = sendCommand(ISO15693_Select,DATA,9,buffer,&Statue); 657 | if (result != 0) 658 | return result; 659 | return Statue; 660 | } 661 | 662 | 663 | int API_ResetToReady(unsigned char flags, unsigned char *uid, unsigned char *buffer) 664 | { 665 | int Statue; 666 | int num; 667 | unsigned char DATA[9]; 668 | DATA[0] = flags; 669 | num = 1; 670 | if (flags == 0x22) 671 | { 672 | copyData(uid, 0, DATA, 1 ,8); 673 | num = 9; 674 | } 675 | int result = sendCommand(ISO15693_Resetready,DATA,num,buffer,&Statue); 676 | if (result != 0) 677 | return result; 678 | return Statue; 679 | } 680 | 681 | 682 | int API_WriteAFI(unsigned char flags, unsigned char afi, unsigned char *uid, unsigned char *buffer) 683 | { 684 | int Statue; 685 | int num; 686 | unsigned char DATA[10]; 687 | DATA[0] = flags; 688 | DATA[1] = afi; 689 | num = 2; 690 | if (flags == 0x22) 691 | { 692 | copyData(uid, 0, DATA, 2 ,8); 693 | num = 10; 694 | } 695 | int result = sendCommand(ISO15693_Write_Afi,DATA,num,buffer,&Statue); 696 | if (result != 0) 697 | return result; 698 | return Statue; 699 | } 700 | 701 | 702 | int API_LockAFI(unsigned char flags, unsigned char *uid, unsigned char *buffer) 703 | { 704 | int Statue; 705 | int num; 706 | unsigned char DATA[9]; 707 | DATA[0] = flags; 708 | num = 1; 709 | if (flags == 0x22) 710 | { 711 | copyData(uid, 0, DATA, 1 ,8); 712 | num = 9; 713 | } 714 | int result = sendCommand(ISO15693_Lock_Afi,DATA,num,buffer,&Statue); 715 | if (result != 0) 716 | return result; 717 | return Statue; 718 | } 719 | 720 | 721 | int API_WriteDSFID(unsigned char flags, unsigned char DSFID, unsigned char *uid, unsigned char *buffer) 722 | { 723 | int Statue; 724 | int num; 725 | unsigned char DATA[10]; 726 | DATA[0] = flags; 727 | DATA[1] = DSFID; 728 | num = 2; 729 | if (flags == 0x22) 730 | { 731 | copyData(uid, 0, DATA, 2 ,8); 732 | num = 10; 733 | } 734 | int result = sendCommand(ISO15693_Write_Dsfid,DATA,num,buffer,&Statue); 735 | if (result != 0) 736 | return result; 737 | return Statue; 738 | } 739 | 740 | 741 | int API_LockDSFID(unsigned char flags, unsigned char *uid, unsigned char *buffer ) 742 | { 743 | int Statue; 744 | int num; 745 | unsigned char DATA[9]; 746 | DATA[0] = flags; 747 | num = 1; 748 | if (flags == 0x22) 749 | { 750 | copyData(uid, 0, DATA, 1 ,8); 751 | num = 9; 752 | } 753 | int result = sendCommand(ISO15693_Lock_Dsfid,DATA,num,buffer,&Statue); 754 | if (result != 0) 755 | return result; 756 | return Statue; 757 | } 758 | 759 | 760 | int API_ISO15693_GetSysInfo(unsigned char flags, unsigned char *uid, unsigned char *buffer) 761 | { 762 | int Statue; 763 | int num; 764 | unsigned char DATA[9]; 765 | DATA[0] = flags; 766 | num = 1; 767 | if (flags == 0x22) 768 | { 769 | copyData(uid, 0, DATA, 1 ,8); 770 | num = 9; 771 | } 772 | int result = sendCommand(ISO15693_Get_Information,DATA,num,buffer,&Statue); 773 | if (result != 0) 774 | return result; 775 | return Statue; 776 | } 777 | 778 | 779 | int API_ISO15693_GetMulSecurity(unsigned char flags, unsigned char blkAddr, unsigned char blkNum, unsigned char *uid, unsigned char *pBuffer) 780 | { 781 | int Statue; 782 | int num; 783 | unsigned char DATA[11]; 784 | DATA[0] = flags; 785 | DATA[1] = blkAddr; 786 | DATA[2] = blkNum; 787 | num = 3; 788 | if (flags == 0x22) 789 | { 790 | copyData(uid, 0, DATA, 3 ,8); 791 | num = 11; 792 | } 793 | int result = sendCommand(ISO15693_Get_Multiple_Block_Security,DATA,num,pBuffer,&Statue); 794 | if (result != 0) 795 | return result; 796 | return Statue; 797 | } 798 | 799 | 800 | int API_ISO15693TransCOSCmd(unsigned char *cmd, int cmdSize, unsigned char *buffer) 801 | { 802 | int Statue; 803 | unsigned char DATA[256]; 804 | DATA[0] = cmdSize; 805 | copyData(buffer,0,DATA,1,cmdSize); 806 | int result = sendCommand(ISO15693_Transfer_Command,DATA,cmdSize,buffer,&Statue); 807 | if (result != 0) 808 | return result; 809 | return Statue; 810 | } 811 | 812 | int UL_HLRead(unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer) 813 | { 814 | int Statue; 815 | unsigned char DATA[23]; 816 | DATA[0] = mode; 817 | DATA[1] = blk_add; 818 | int result = sendCommand(CMD_UL_HLRead,DATA,2,DATA,&Statue); 819 | if (result != 0) 820 | return result; 821 | copyData(DATA,0,buffer,0,16); 822 | copyData(DATA,16,snr,0,7); 823 | return Statue; 824 | } 825 | 826 | 827 | int UL_HLWrite(unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer) 828 | { 829 | int Statue; 830 | unsigned char DATA[7]; 831 | DATA[0] = mode; 832 | DATA[1] = 1; 833 | DATA[2] = blk_add; 834 | copyData(buffer, 0, DATA, 3, 4); 835 | int result = sendCommand(CMD_UL_HLWrite,DATA,7,snr,&Statue); 836 | if (result != 0) 837 | return result; 838 | return Statue; 839 | } 840 | 841 | 842 | int UL_Request(unsigned char mode,unsigned char *snr) 843 | { 844 | int Statue; 845 | unsigned char DATA[1]; 846 | DATA[0] = mode; 847 | int result = sendCommand(CMD_UL_Request,DATA,1,snr,&Statue); 848 | if (result != 0) 849 | return result; 850 | return Statue; 851 | } 852 | -------------------------------------------------------------------------------- /function.h: -------------------------------------------------------------------------------- 1 | //System Setting 2 | 3 | int API_SetSerNum( unsigned char *newValue, unsigned char *buffer); 4 | 5 | int API_GetSerNum( unsigned char *buffer); 6 | 7 | int WriteUserInfo( int num_blk, int num_length, char *user_info); 8 | 9 | int ReadUserInfo( int num_blk, int num_length, char *user_info); 10 | 11 | int GetVersionNum( char *VersionNum); 12 | 13 | int API_ControlLED( unsigned char freq, unsigned char duration, unsigned char *buffer); 14 | 15 | int API_ControlBuzzer( unsigned char freq, unsigned char duration, unsigned char *buffer); 16 | 17 | //ISO14443A 18 | int MF_Request( unsigned char inf_mode, unsigned char *buffer); 19 | 20 | int MF_Anticoll( unsigned char *snr, unsigned char *tatus); 21 | 22 | int MF_Select( unsigned char *snr); 23 | 24 | int MF_Halt(void); 25 | 26 | int API_PCDRead( unsigned char mode, unsigned char blk_add, unsigned char num_blk, unsigned char *snr, unsigned char *buffer); 27 | 28 | int API_PCDWrite( unsigned char mode, unsigned char blk_add, unsigned char num_blk, unsigned char *snr, unsigned char *buffer); 29 | 30 | int API_PCDInitVal( unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value); 31 | 32 | int API_PCDDec( unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value); 33 | 34 | int API_PCDInc( unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value); 35 | 36 | int GET_SNR( unsigned char mode, unsigned char API_halt, unsigned char *snr, unsigned char*value); 37 | 38 | int MF_Restore( unsigned char mode, int cardlength, unsigned char*carddata ); 39 | 40 | //ISO14443B 41 | int RequestType_B( unsigned char *buffer); 42 | 43 | int AntiType_B( unsigned char *buffer); 44 | 45 | int SelectType_B( unsigned char*SerialNum); 46 | 47 | int Request_AB( unsigned char* buffer); 48 | 49 | int API_ISO14443TypeBTransCOSCmd( unsigned char *cmd, int cmdSize, unsigned char *buffer); 50 | 51 | //ISO15693 52 | int API_ISO15693_Inventory( unsigned char flag, unsigned char afi, unsigned char *pData, unsigned char *nrOfCard, unsigned char *pBuffer); 53 | 54 | int API_ISO15693Read( unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *buffer); 55 | 56 | int API_ISO15693Write( unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *data); 57 | 58 | int API_ISO15693Lock( unsigned char flags, unsigned char num_blk, unsigned char *uid, unsigned char *buffer); 59 | 60 | int API_ISO15693StayQuiet( unsigned char flags, unsigned char *uid, unsigned char *buffer); 61 | 62 | int API_ISO15693Select( unsigned char flags, unsigned char *uid, unsigned char *buffer); 63 | 64 | int API_ResetToReady( unsigned char flags, unsigned char *uid, unsigned char *buffer); 65 | 66 | int API_WriteAFI( unsigned char flags, unsigned char afi, unsigned char *uid, unsigned char *buffer); 67 | 68 | int API_LockAFI( unsigned char flags, unsigned char *uid, unsigned char *buffer); 69 | 70 | int API_WriteDSFID( unsigned char flags, unsigned char DSFID, unsigned char *uid, unsigned char *buffer); 71 | 72 | int API_LockDSFID(unsigned char flags, unsigned char *uid, unsigned char *buffer ); 73 | 74 | int API_ISO15693_GetSysInfo( unsigned char flags, unsigned char *uid, unsigned char *buffer); 75 | 76 | int API_ISO15693_GetMulSecurity( unsigned char flags, unsigned char blkAddr, unsigned char blkNum, unsigned char *uid, unsigned char *pBuffer); 77 | 78 | int API_ISO15693TransCOSCmd( unsigned char *cmd, int cmdSize, unsigned char *buffer); 79 | 80 | //ultralight 81 | int UL_HLRead(unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer); 82 | 83 | int UL_HLWrite( unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer); 84 | 85 | int UL_Request( unsigned char mode,unsigned char *snr); 86 | -------------------------------------------------------------------------------- /test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "function.h" 4 | int main() 5 | { 6 | unsigned char buffer; 7 | int result; 8 | result = API_ControlBuzzer(0x0a,0x0a,&buffer); 9 | printf("result:%02x buffer:%02x\n",result,buffer); 10 | return 0; 11 | } 12 | --------------------------------------------------------------------------------