how to implemnt try and except to read data from RFID using sllurp

ajay_sahare

Ajay sahare

Posted on May 18, 2022

how to implemnt try and except to read data from RFID using sllurp

Hi,
I want to implement to try and except in the following code if the connection is True then only I am able to read RFIDF tag .and I am not able to understand how slllrp Libary make a connection between Reader and Tag

from sllurp import llrp
from twisted.internet import reactor
import logging
logging.getLogger().setLevel(logging.INFO)

def cb(tagReport):
    try:
        mylist = []
        tags = tagReport.msgdict['RO_ACCESS_REPORT']['TagReportData']
        if not len(tags)==0:
             mylist.append(tags)
        print(mylist[0][0]['EPC-96'])
    except:
         print('error')

factory = llrp.LLRPClientFactory(antennas=[1], duration=1,session=0,tx_power=0,start_inventory=True)

factory.addTagReportCallback(cb)
reactor.connectTCP('192.168.120.501', llrp.LLRP_PORT, factory)
reactor.run()
Enter fullscreen mode Exit fullscreen mode

My code is working fine I can read the tag but I want to apply to try and except block and I do not understand how to do it in that code
whenever my reader is connected only that time I can read the tag otherwise it goes under except block which method do I use to check the current status of the connection object?

💖 💪 🙅 🚩
ajay_sahare
Ajay sahare

Posted on May 18, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related