예제 #1
0
파일: old.c 프로젝트: TurpIF/pi-nfc
phStatus_t forceReadSector(uint8_t sector_id, uint8_t ** keys, uint16_t nbKeys, uint8_t * data) {
  uint8_t bSak[1];
  uint8_t bUid[10];
  uint8_t bNbCards;
  uint8_t bLength;
  uint16_t i;
  PH_CHECK_SUCCESS_FCT(status, search_card(bUid, &bLength, bSak, &bNbCards));
  for (i = 0; i < nbKeys; i++) {
    if (readSector(sector_id, keys[i], PHAL_MFC_KEYA, bUid, data) == PH_ERR_SUCCESS)
      return PH_ERR_SUCCESS;
    PH_CHECK_SUCCESS_FCT(status, search_card(bUid, &bLength, bSak, &bNbCards));
    if (readSector(sector_id, keys[i], PHAL_MFC_KEYB, bUid, data) == PH_ERR_SUCCESS)
      return PH_ERR_SUCCESS;
    PH_CHECK_SUCCESS_FCT(status, search_card(bUid, &bLength, bSak, &bNbCards));
  }
  return PH_ERR_AUTH_ERROR;
}
예제 #2
0
void main(void)
    {
    char *fname = "NAMECARD.DAT";
    char name[NAME_SIZE];
    int i;
    card *t;
    init_card();
    while ((i = select_menu()) != 8)
        {
        switch (i)
            {
            case 1 : input_card();
                     break;
            case 2 : printf("\n    Input name to delete -> ");
                     gets(name);
                     if (!delete_card(name))
                         printf("\n        Can't find that name.");
                     break;
            case 3 : printf("\n    Input name to search -> ");
                     gets(name);
                     t = search_card(name);
                     if (t == NULL)
                         {
                         printf("\n        Can't find that name.");
                         break;
                         }
                     print_header(stdout);
                     print_card(t, stdout);
                     break;
            case 4 : load_cards(fname);
                     break;
            case 5 : save_cards(fname);
                     break;
            case 6 : t = head->next;
                     print_header(stdout);
                     while (t != tail)
                         {
                         print_card(t, stdout);
                         t = t->next;
                         }
                     break;
            case 7 : t = head->next;
                     print_header(stdprn);
                     while (t != tail)
                         {
                         print_card(t, stdprn);
                         t = t->next;
                         }
                     break;
            }
        }
    printf("\n\nProgram ends...");
    }
예제 #3
0
파일: main.c 프로젝트: jacoby3108/wiegand01
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    chusma1=BCSCTL1;
    chusma2=CALBC1_1MHZ;

    chusma3=DCOCTL;
    chusma4=CALDCO_1MHZ;


    /// P1SEL &=~(BUTTON |GREEN | RED );

//****************Measurement of SMCLK********************************************************
// if SHOW_SMCLK is enabled (=1) smclk signal is visible on P1.4 useful to measure system clk
// (WARNING !! if this test is enabled only scope should be connected to  P1.4  )
#define SHOW_SMCLK 0		// =1 Show System bus clk / =0 Normal I/O operation
//*****************************************************************************************



#if SHOW_SMCLK     // show SMCLK on P1.4  (WARNING !! only scope should be connected to  P1.4  )

    P1SEL=IO_FUNCTION | P1_4 ;  // select SMCLK as primary function
    P1SEL2=IO_FUNCTION;
    P1DIR |= P1_4;  // P1.4 as output "required"
    for(;;){}  // Endless loop

#else
    P1SEL=IO_FUNCTION;
    P1SEL2=IO_FUNCTION;
    P1DIR |= (GREEN | RED);
#endif



    P1IES &= ~ (WIEGAND_0 | WIEGAND_1); //Rising edge


    P1REN |= PULLUPS;  // Enable Pull up/down resistors (THIS DISABLES SMCLK WHY ???)

    P1IFG &= ~(BUTTON | P1_4 | P1_5); // Clear pending flags
    P1IE |= (P1_4 | P1_5);   // Enable P1 Interrupts

    lamp=GREEN;

    P1OUT = lamp | PULLUPS;



    init_wiegand();
   init_timer();


    _BIS_SR(GIE);



	for(;;) {
		volatile unsigned int i;	// volatile to prevent optimization

		// P1OUT ^= lamp;				// Toggle P1.0 using exclusive-OR

		i = 10000;				// SW Delay
		do i--;
		while(i != 0);

		if(wiegand_get_status())  // if a card was read
		{

			facility_code=wiegand_get_card_fc(); // get fc
			itoa(facility_code,card_fc,10); //Convert to string
			card_nr= wiegand_get_card_number(); // then get its data
			itoa(card_nr,card_number,10); //Convert to string

			if(search_card()==FOUND)			//search card on table
			open_door();

		}



	}




	
	return 0;
}