From 0640ed9d99a82857fb80f97a3ea33bee587faf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Ates?= Date: Fri, 24 May 2013 17:11:57 +0200 Subject: [PATCH] Demonstration script. --- demo.py | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 demo.py diff --git a/demo.py b/demo.py new file mode 100755 index 0000000..b64a6f3 --- /dev/null +++ b/demo.py @@ -0,0 +1,93 @@ +#!/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 . + + + Demo +''' + + +import models +import utils +import core_standard +from stid_readers import core as stid_core + + +if __name__ == '__main__': + reader = models.RFIDReader() + 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: + 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: + 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: + 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)