示例#1
0
bool EM2874Device::writeICC ( const size_t size, const void *data )
{
	uint8_t val;
	if( getCardStatus() != 0x5 )
		return false;
	writeReg( EM2874_REG_CAS_MODE1, 0x01 );

	usbdevfs_ctrltransfer ctrl1 = {USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_DEVICE, 0x14, 0, 0, 0, USBREQ_TIMEOUT, NULL};

	uint8_t cardBuf[256];
	cardBuf[0] = 0;
	cardBuf[1] = cardPCB;
	cardBuf[2] = size;
	memcpy( cardBuf+3, data, size );
	cardBuf[size+3] = ICC_checkSum( cardBuf+1, size+2 );
	val = size + 4;

	for(int i = 0; i < val; i+=64 ) {
		ctrl1.wIndex = 0x200 + i;
		ctrl1.wLength = (val - i) > 64 ? 64 : (val - i);
		ctrl1.data = cardBuf+i;
		if(usb_ctrl(fd, &ctrl1) < 0) {
			return false;
		}
	}

	cardPCB ^= 0x40;
	writeReg( EM2874_REG_CAS_MODE2, 0);
	readReg( EM2874_REG_CAS_STATUS, &val );

	writeReg( EM2874_REG_CAS_DATALEN, size + 4 );
	miliWait(1);
	return true;
}
示例#2
0
bool EM2874Device::resetICC_1 ()
{
	if(getCardStatus() == 0x5 &&
	writeReg( EM2874_REG_CAS_MODE1, 0x1 ) &&
	writeReg( EM2874_REG_CAS_RESET, 0x1 )
	) {
		return true;
	}
	return false;
}
示例#3
0
/**
 * RIL_REQUEST_GET_SIM_STATUS
 *
 * Requests status of the SIM interface and the SIM card.
 *
 * Valid errors:
 *  Must never fail.
 */
void requestGetSimStatus(void *data, size_t datalen, RIL_Token t)
{
    (void) data; (void) datalen;
    RIL_CardStatus_v6* p_card_status = NULL;

    if (getCardStatus(&p_card_status) != RIL_E_SUCCESS)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, (char*)p_card_status, sizeof(*p_card_status));

finally:
    if (p_card_status != NULL)
        freeCardStatus(p_card_status);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}