pub fn select(&mut self, _atqa: &AtqA) -> Result<Uid, Error<E>> {
        let rx = self.transceive::<U5>(&[picc::SEL_CL1, 0x20], 0)?;

        assert_ne!(
            rx[0],
            picc::CT,
            "double and triple size UIDs are currently not supported"
        );

        let expected_bcc = rx[4];
        let computed_bcc = rx[0] ^ rx[1] ^ rx[2] ^ rx[3];

        // XXX can this ever fail? (buggy PICC?)
        if computed_bcc != expected_bcc {
            return Err(Error::Bcc);
        }

        let mut tx: [u8; 9] = unsafe { mem::uninitialized() };
        tx[0] = picc::SEL_CL1;
        tx[1] = 0x70;
        tx[2..7].copy_from_slice(&rx);

        let crc = self.calculate_crc(&tx[..7])?;
        tx[7..].copy_from_slice(&crc);

        // enable automatic CRC validation during reception
        let rx2 = self.transceive::<U3>(&tx, 0)?;

        let crc2 = self.calculate_crc(&rx2[..1])?;

        if &rx2[1..] != &crc2 {
            return Err(Error::Crc);
        }

        let sak = rx2[0];

        let compliant = match (sak & (1 << 2) != 0, sak & (1 << 5) != 0) {
            // indicates that the UID is incomplete -- this is unreachable because we only support
            // single size UIDs
            (_, true) => unreachable!(),
            (true, false) => true,
            (false, false) => false,
        };

        Ok(Uid {
            bytes: [rx[0], rx[1], rx[2], rx[3]],
            compliant,
        })
    }
/// Selects an idle PICC
///
/// NOTE currently this only supports single size UIDs
// TODO anticollision loop
// TODO add optional UID to select an specific PICC
Selects an idle PICC
NOTE currently this only supports single size UIDs
TODO anticollision loop
TODO add optional UID to select an specific PICC
Selects an idle PICC NOTE currently this only supports single size UIDs TODO anticollision loop TODO add optional UID to select an specific PICC
pub fn select(&mut self, _atqa: &AtqA) -> Result<Uid, Error<E>> {
        let rx = self.transceive::<U5>(&[picc::SEL_CL1, 0x20], 0)?;
        assert_ne!(
            rx[0],
            picc::CT,
            "double and triple size UIDs are currently not supported"
        );
        let expected_bcc = rx[4];
        let computed_bcc = rx[0] ^ rx[1] ^ rx[2] ^ rx[3];
        // XXX can this ever fail? (buggy PICC?)
        if computed_bcc != expected_bcc {
            return Err(Error::Bcc);
        }
        let mut tx: [u8; 9] = unsafe { mem::uninitialized() };
        tx[0] = picc::SEL_CL1;
        tx[1] = 0x70;
        tx[2..7].copy_from_slice(&rx);
        let crc = self.calculate_crc(&tx[..7])?;
        tx[7..].copy_from_slice(&crc);
        // enable automatic CRC validation during reception
        let rx2 = self.transceive::<U3>(&tx, 0)?;
        let crc2 = self.calculate_crc(&rx2[..1])?;
        if &rx2[1..] != &crc2 {
            return Err(Error::Crc);
        }
        let sak = rx2[0];
        let compliant = match (sak & (1 << 2) != 0, sak & (1 << 5) != 0) {
            // indicates that the UID is incomplete -- this is unreachable because we only support
            // single size UIDs
            (_, true) => unreachable!(),
            (true, false) => true,
            (false, false) => false,
        };
        Ok(Uid {
            bytes: [rx[0], rx[1], rx[2], rx[3]],
            compliant,
        })
    }
pub fn select ( & mut self , _atqa : & AtqA ) -> Result < Uid , Error < E > > { let rx = self . transceive :: < U5 > ( & [ picc :: SEL_CL1 , 0x20 ] , 0 ) ? ; assert_ne ! ( rx [ 0 ] picc CT " " ) ; let expected_bcc = rx [ 4 ] ; let computed_bcc = rx [ 0 ] ^ rx [ 1 ] ^ rx [ 2 ] ^ rx [ 3 ] ; // XXX can this ever fail? (buggy PICC?) if computed_bcc != expected_bcc { return Err ( Error :: Bcc ) ; } let mut tx : [ u8 ; 9 ] = unsafe { mem :: uninitialized ( ) } ; tx [ 0 ] = picc :: SEL_CL1 ; tx [ 1 ] = 0x70 ; tx [ 2 .. 7 ] . copy_from_slice ( & rx ) ; let crc = self . calculate_crc ( & tx [ .. 7 ] ) ? ; tx [ 7 .. ] . copy_from_slice ( & crc ) ; // enable automatic CRC validation during reception let rx2 = self . transceive :: < U3 > ( & tx , 0 ) ? ; let crc2 = self . calculate_crc ( & rx2 [ .. 1 ] ) ? ; if & rx2 [ 1 .. ] != & crc2 { return Err ( Error :: Crc ) ; } let sak = rx2 [ 0 ] ; let compliant = match ( sak & ( 1 << 2 ) != 0 , sak & ( 1 << 5 ) != 0 ) { // indicates that the UID is incomplete -- this is unreachable because we only support // single size UIDs ( _ , true ) => unreachable ! ( ) , ( true , false ) => true , ( false , false ) => false , } ; Ok ( Uid { bytes : [ rx [ 0 ] , rx [ 1 ] , rx [ 2 ] , rx [ 3 ] ] , compliant , } ) }
Selects an idle PICC
NOTE currently this only supports single size UIDs
TODO anticollision loop
TODO add optional UID to select an specific PICC
Selects an idle PICC NOTE currently this only supports single size UIDs TODO anticollision loop TODO add optional UID to select an specific PICC
&mut self
_atqa
&AtqA