
"""Configure the PN532 to read MiFare cards.""" Return (response, response, response, response) Raise RuntimeError('Failed to detect the PN532! Make sure there is sufficient power (use a 1 amp or greater power supply), the PN532 is wired correctly to the device, and the solder joints on the PN532 headers are solidly connected.')

Response = self.call_function(PN532_COMMAND_GETFIRMWAREVERSION, 4) """Call PN532 GetFirmwareVersion function and return a tuple with the IC, """Initialize communication with the PN532. Raise RuntimeError('Received unexpected command response!') If not (response = PN532_PN532TOHOST and response = (command+1)): # Check that response is for the called function. Response = self._read_frame(response_length+2) # Build frame data with command and parameters. Response is available within the timeout. Will wait up to timeout_secs secondsįor a response and return a bytearray of response bytes, or None if no Note that less than the expected bytes mightīe returned! Params can optionally specify an array of bytes to send as """Send specified command to the PN532 and expect up to response_lengthīytes back in a response. Return responseĭef call_function(self, command, response_length=0, params=, timeout_sec=1): Raise RuntimeError('Response checksum did not match expected value!') # Check frame checksum value matches bytes.Ĭhecksum = reduce(self._uint8_add, response, 0) Raise RuntimeError('Response length checksum did not match length!') Raise RuntimeError('Response contains no data!') Raise RuntimeError('Response frame preamble does not contain 0x00FF!') # Swallow all the 0x00 values that preceed 0xFF. Raise RuntimeError('Response frame does not start with 0x01!') If not (PN532_ACK_FRAME = response.tostring()): # Check frame starts with 0x01 and then has 0x00FF (preceeded by optional # Read frame with expected length of data. Returns the data inside the frame if found, otherwise raises an exception """Read a response frame from the PN532 of at most length bytes in size. """Busy wait for the specified number of milliseconds.""" """Add two values as unsigned 8-bit values.""" r = serial.Serial(uart_port, uart_baudrate, timeout=2000) # Prefixes for NDEF Records (to identify record type) PN532_RESPONSE_INLISTPASSIVETARGET = 0x4B PN532_COMMAND_TGRESPONSETOINITIATOR = 0x90 PN532_COMMAND_TGGETINITIATORCOMMAND = 0x88
MIFARE CRACKER SOFTWARE
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included in all # furnished to do so, subject to the following conditions:

# copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
MIFARE CRACKER FREE
# Permission is hereby granted, free of charge, to any person obtaining a copy # Author: Manuel Fernando Galindo Copyright (c) 2016 Manuel Fernando Galindo # Example of detecting and reading a block from a MiFare NFC card.
