Exemplo n.º 1
0
static int init()
{
	unsigned char buf[0x3f];
	int rc;

	printf("initializing librfid\n");
	rfid_init();

	printf("opening reader handle\n");
	rh = rfid_reader_open(NULL, RFID_READER_CM5121);
	if (!rh) {
		fprintf(stderr, "error, no cm5121 handle\n");
		return -1;
	}

	printf("opening layer2 handle\n");
	l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A);
	//l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443B);
	if (!l2h) {
		fprintf(stderr, "error during iso14443a_init\n");
		return -1;
	}

	//rc632_register_dump(rh->ah, buf);

	printf("running layer2 anticol\n");
	rc = rfid_layer2_open(l2h);
	if (rc < 0) {
		fprintf(stderr, "error during layer2_open\n");
		return rc;
	}

	return 0;
}
void _init_func(void)
{
	DEBUGPCRF("enabling RC632");	
	rc632_init();

	DEBUGPCRF("turning on RF");
	rc632_turn_on_rf(RAH);

	DEBUGPCRF("initializing 14443A operation");
	rh = rfid_reader_open(NULL, RFID_READER_OPENPCD);
	l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A);
		
	DEBUGPCRF("registering USB handler");
	usb_hdlr_register(&usb_presence_rx, OPENPCD_CMD_CLS_PRESENCE);
	
	delay_scan=delay_blink=0;
	last_uid=0;
}
Exemplo n.º 3
0
EXPORT int EXPORT_CONVENTION openpcd_select_card(MIFARE_HANDLE handle)
{
    int res;
    struct openpcd_state *state;
        
    if(!handle)
	return PCDERROR_INVALID_PARAMETER;
    state=(struct openpcd_state*)handle;
    
    state->l2h = rfid_layer2_init(state->rh,RFID_LAYER2_ISO14443A);
    if(!state->l2h)
	res=PCDERROR_LAYER2_INIT;
    else
    {        
	if( rfid_layer2_open(state->l2h)>=0 ) 
	{
    	    state->ph = rfid_protocol_init(state->l2h,RFID_PROTOCOL_MIFARE_CLASSIC);
	
	    if(state->ph)
    	    {
		if(rfid_protocol_open(state->ph)>=0)
	    	    return PCDERROR_NONE;
		
		rfid_protocol_fini(state->ph);
		state->ph=NULL;
	
		res=PCDERROR_LAYER3_OPEN;
	    }
	    else
		res=PCDERROR_LAYER3_INIT;

	    rfid_layer2_close(state->l2h);	
        }
	else
    	    res=PCDERROR_LAYER2_OPEN;
    }
    
    rfid_layer2_fini(state->l2h);
    state->l2h=NULL;
    
    return res;	
}
Exemplo n.º 4
0
static int l2_init(int layer2)
{
	int rc;

	printf("opening layer2 handle\n");
	l2h = rfid_layer2_init(rh, layer2);
	if (!l2h) {
		fprintf(stderr, "error during layer2(%d)_init (0=14a,1=14b,3=15)\n",layer2);
		return -1;
	}

	printf("running layer2 anticol(_open)\n");
	rc = rfid_layer2_open(l2h);
	if (rc < 0) {
		fprintf(stderr, "error during layer2_open\n");
		return rc;
	}

	return 0;
}