I am using a RFID reader to scan multiple RFID tags. The readings are placed into a list. I am trying to check if a tag is in the reading. Using the 'if in' method is not working for me.
import mercury
import time
reader = mercury.Reader("tmr:///dev/ttyUSB0")
reader.set_region("EU3")
reader.set_read_plan([1], "GEN2")
tag1 = 'E2004005730702602190360B'
tag2 = 'E20040057307026421903619'
while True:
a = reader.read()
print (a)
print(type(a))
if tag1 in a:
print('tag1')
time.sleep(0.2)
break
if tag2 in a:
print('tag2')
time.sleep(0.2)
break
time.sleep(0.2)
My terminal is output is:
['E20040057307026421903619', 'E2004005730702602190360B']
<type 'list'>
So the if conditions is not executed when tag1 or tag2 are in a.
I can't seem to make it enter the if condition. Any advice?
type(a)as well? and paste the output of your console as text not as image (so we can try to reproduce)print(a[0],type(a[0])to be sure of the type of the items and which they are ? (sorry, I should have asked earlier)