Merge pull request #30 from FoamyGuy/master

Change get_firmware_version() function to a property
This commit is contained in:
Kattni 2020-03-17 15:23:09 -04:00 committed by GitHub
commit 42192bfeaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions

View file

@ -196,11 +196,11 @@ class PN532:
try:
self._wakeup()
self.get_firmware_version() # first time often fails, try 2ce
_ = self.firmware_version # first time often fails, try 2ce
return
except (BusyError, RuntimeError):
pass
self.get_firmware_version()
_ = self.firmware_version
def _read_data(self, count):
# Read raw data from device, not including status bytes:
@ -317,7 +317,8 @@ class PN532:
# Return response data.
return response[2:]
def get_firmware_version(self):
@property
def firmware_version(self):
"""Call PN532 GetFirmwareVersion function and return a tuple with the IC,
Ver, Rev, and Support values.
"""

View file

@ -62,7 +62,7 @@ pn532 = PN532_I2C(i2c, debug=False)
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
#pn532 = PN532_UART(uart, debug=False)
ic, ver, rev, support = pn532.get_firmware_version()
ic, ver, rev, support = pn532.firmware_version
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
# Configure PN532 to communicate with MiFare cards

View file

@ -58,7 +58,7 @@ pn532 = PN532_SPI(spi, cs_pin, debug=False)
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
#pn532 = PN532_UART(uart, debug=False)
ic, ver, rev, support = pn532.get_firmware_version()
ic, ver, rev, support = pn532.firmware_version
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
# Configure PN532 to communicate with MiFare cards

View file

@ -38,7 +38,7 @@ pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
#uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
#pn532 = PN532_UART(uart, debug=False)
ic, ver, rev, support = pn532.get_firmware_version()
ic, ver, rev, support = pn532.firmware_version
print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
# Configure PN532 to communicate with MiFare cards