Skip to content

Change get_firmware_version() function to a property #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions adafruit_pn532/adafruit_pn532.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ def __init__(self, *, debug=False, reset=None):

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:
Expand Down Expand Up @@ -317,7 +317,8 @@ def call_function(self, command, response_length=0, params=[], timeout=1): # pyl
# 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.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/pn532_readwrite_mifare.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#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
Expand Down
2 changes: 1 addition & 1 deletion examples/pn532_readwrite_ntag2xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#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
Expand Down
2 changes: 1 addition & 1 deletion examples/pn532_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#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
Expand Down