Phidgets 1024 Attaches but does not read... sometimes

Supporting 2.6 and up
Post Reply
BissontzJ
Fresh meat
Posts: 1
Joined: Wed Jul 31, 2019 6:36 am
Contact:

Phidgets 1024 Attaches but does not read... sometimes

Post by BissontzJ »

I have a Phidgets 1024_0 RFID Reader attached to a Raspberry Pi 3 B+. Most of the time the software provided by Phidgets works, as well as software I wrote myself. But after a random amount of times it takes the Attach event slightly longer to occur and after it has attached it will not read any tags. If I terminate the program and start it again it usually will run fine again. Until another random amount of runs and it'll happen again. I've narrowed it down to the problem occuring during either the ch.open() or ch.openWaitForAttachment() commands. Whatever is happening is causing TagPresent events to not occur.

Code: Select all

# Create the Phidgets channel object
	#print("Creating channel object")
        ch = RFID()

        # Set the RFID parameters
	#print("Setting RFID parameters") 
        ch.setDeviceSerialNumber(380920)
        ch.setIsHubPortDevice(False)
        ch.setChannel(0)
        
        # Set device handlers
	#print("Setting handlers")
        ch.setOnAttachHandler(onAttachHandler)
        ch.setOnDetachHandler(onDetachHandler)
        ch.setOnErrorHandler(onErrorHandler)
        ch.setOnTagHandler(onTagHandler)
        ch.setOnTagLostHandler(onTagLostHandler)
	#print("Handlers have been set")
        
        try:
            ch.open()
        except PhidgetException as e:
	    PrintOpenErrorMessage(e, ch)
            raise EndProgramSignal("Program Terminated: Open Failed")

	print("Entering while loop")
        while((ch.getTagPresent() == False) and (currentRFID != "Empty")):
            time.sleep(0.1)
	    RFIDFile = open('/var/tmp/RFIDOut.txt', 'r')
            currentRFID = RFIDFile.readline()
            RFIDFile.close()
            
        ch.close()
        print("\nExiting...")
	sys.stdout.flush()
	sys.stdout.close()

	sys.stderr.flush()
	sys.stderr.close()
        return 0
I have attached my code, I have the RFID sit in a while loop looking for a tag. As soon as it finds a tag or the word "Empty" is written to my RFID file it will break out and close. Again, the error occurs with both my code shown as well with the RFID code provided by Phidgets. No error code is raised when it happens, it just sits there waiting for a tag to be present but won't detect them.

Any help would be greatly appreciated
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests