Adapt demo due to direct core function access removal.
This commit is contained in:
parent
99c9e0036a
commit
9292e30f32
89
demo.py
89
demo.py
|
@ -21,7 +21,6 @@
|
|||
Demo
|
||||
'''
|
||||
|
||||
|
||||
import models
|
||||
import utils
|
||||
import core_standard
|
||||
|
@ -30,47 +29,15 @@ from stid_readers import core as stid_core
|
|||
|
||||
if __name__ == '__main__':
|
||||
reader = models.RFIDReader()
|
||||
print 'Get_RFSettings'
|
||||
try:
|
||||
command = models.ReaderCommand(command_name='Get_RFSettings',
|
||||
reader=reader)
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
logic_ports = stid_core.get_rfsettings(response)
|
||||
i = 0
|
||||
for logic_port in logic_ports:
|
||||
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
|
||||
print "Logic port: %s" % i
|
||||
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
|
||||
print "\tPowerAnt: %s dBm" % logic_port['PowerAnt']
|
||||
print "\tAntNb: %s" % logic_port['AntNb']
|
||||
i += 1
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
try:
|
||||
logic_port = {\
|
||||
'ScanDelay': 700,
|
||||
'PowerAnt': 31,
|
||||
'AntNb': 0,
|
||||
}
|
||||
logic_ports = [logic_port]
|
||||
data = stid_core.set_rfsettings(logic_ports)
|
||||
command = models.ReaderCommand(command_name='Set_RFSettings',
|
||||
reader=reader, data=data)
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
try:
|
||||
command = models.ReaderCommand(command_name='Get_RFSettings',
|
||||
reader=reader)
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
logic_ports = stid_core.get_rfsettings(response)
|
||||
i = 0
|
||||
for logic_port in logic_ports:
|
||||
for logic_port in response.processed_data:
|
||||
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
|
||||
print "Logic port: %s" % i
|
||||
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
|
||||
|
@ -79,13 +46,61 @@ if __name__ == '__main__':
|
|||
i += 1
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
|
||||
print 'Inventory'
|
||||
try:
|
||||
command = models.Command(command_name='Inventory')
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
tags = core_standard.inventory(response)
|
||||
for tag in tags:
|
||||
for tag in response.processed_data:
|
||||
print "Tag: %s" % tag['EPC'].encode('hex')
|
||||
print "\t Read on logic port: %s" % tag['AntID']
|
||||
print "\t Times read on all logic ports: %s" % tag['NbRead']
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
|
||||
print 'Set_RFSettings'
|
||||
try:
|
||||
logic_port = {\
|
||||
'ScanDelay': 800,
|
||||
'PowerAnt': 23,
|
||||
'AntNb': 0,
|
||||
}
|
||||
logic_ports = [logic_port]
|
||||
command = models.ReaderCommand(command_name='Set_RFSettings',
|
||||
reader=reader, data_to_process=logic_ports)
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
|
||||
print 'Get_RFSettings'
|
||||
try:
|
||||
command = models.ReaderCommand(command_name='Get_RFSettings',
|
||||
reader=reader)
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
i = 0
|
||||
for logic_port in response.processed_data:
|
||||
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
|
||||
print "Logic port: %s" % i
|
||||
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
|
||||
print "\tPowerAnt: %s dBm" % logic_port['PowerAnt']
|
||||
print "\tAntNb: %s" % logic_port['AntNb']
|
||||
i += 1
|
||||
except Exception, err:
|
||||
print str(err)
|
||||
|
||||
print 'Inventory'
|
||||
try:
|
||||
command = models.Command(command_name='Inventory')
|
||||
response = reader.send(command)
|
||||
command.pretty_print()
|
||||
response.pretty_print()
|
||||
for tag in response.processed_data:
|
||||
print "Tag: %s" % tag['EPC'].encode('hex')
|
||||
print "\t Read on logic port: %s" % tag['AntID']
|
||||
print "\t Times read on all logic ports: %s" % tag['NbRead']
|
||||
|
|
Reference in New Issue