1

I'm successfully reading data from my NFC tags with the py532lib, using the i2c connection, put out by Hubcitylabs 5 years ago. https://github.com/HubCityLabs/py532lib/blob/master/py532lib/i2c.py

Unfortunately, after running for about 15 minutes, the system crashes with the error:

OSError: Error 24 Too Many Open Files: '/dev/i2c-1'

Here's the portion of code I have written, that's using the library. Anyone have an idea what I need to add in order to actually close out the files? I've done some reading and it sounds like it's leaving open file descriptors (maybe?).

def nfc_list(self):
    Mifare().set_max_retries(5)
    uid = Mifare().scan_field()
    if uid:
        print(uid)
        """Grab the entire output of the NFC mobule from the I2C channel."""
        self.nfc_read = Pn532_i2c().read_mifare().get_data() #Store it in our variable.
        Pn532_i2c().reset_i2c()
        #print('nfc_read = ' + str(self.nfc_read))
    else:
        self.nfc_read = '' #empty out the array
        Pn532_i2c().reset_i2c()
        #print('no tag found')
    self.bus.close()

This thing has been sitting to the side on my desk for a few months now because I just got tired of getting nowhere with it. Any help is greatly appreciated.

  • 1
    are you writing the data to a file in code you haven't shown perhaps? – Jaromanda X Jan 25 at 2:47
  • I'm only reading the tag and using it stored in the variable, nfc_read. My guess is there's a memory leak in that i2c library, linked above, that isn't automatically closing out files that it creates. I manually added the reset_i2c() and bus.close() commands in an attempt to handle this, but it doesn't seem to be working. – Bobby Hill Jan 25 at 13:51
  • Can someone possibly point me to where this file location is? Maybe I can crudely just delete everything in there on every call. – Bobby Hill Feb 9 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.