109 lines
3.7 KiB
Python
Executable File
109 lines
3.7 KiB
Python
Executable File
#!/usr/bin/env python
|
|
'''
|
|
librfid - RFID EPC Class 1 Gen2 / ISO/IEC 18000-6C compliant library
|
|
|
|
Copyright (C) 2013 Entr'ouvert
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
Demo
|
|
'''
|
|
|
|
import models
|
|
import utils
|
|
import core_standard
|
|
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()
|
|
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']
|
|
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']
|
|
except Exception, err:
|
|
print str(err)
|