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):
    uid = Mifare().scan_field()
    if 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.
        #print('nfc_read = ' + str(self.nfc_read))
        self.nfc_read = '' #empty out the array
        #print('no tag found')

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.