Update demo.

This commit is contained in:
Mikaël Ates 2016-02-23 13:02:37 +01:00
parent 21bcb52621
commit e43c8309f7
1 changed files with 30 additions and 11 deletions

41
demo.py
View File

@ -21,14 +21,15 @@
Demo
'''
import models
import utils
import core_standard
# Run with python -m librfid.demo
import librfid
def inventory(reader):
print 'Inventory'
try:
command = models.Command(command_name='Inventory')
command = librfid.Command(command_name='Inventory')
response = reader.send(command)
command.pretty_print()
response.pretty_print()
@ -42,7 +43,7 @@ def inventory(reader):
def get_rf_settings(reader):
print 'Get_RFSettings'
try:
command = models.ReaderCommand(command_name='Get_RFSettings',
command = librfid.ReaderCommand(command_name='Get_RFSettings',
reader=reader)
response = reader.send(command)
command.pretty_print()
@ -67,7 +68,7 @@ def set_rf_settings(reader):
'AntNb': 0,
}
logic_ports = [logic_port]
command = models.ReaderCommand(command_name='Set_RFSettings',
command = librfid.ReaderCommand(command_name='Set_RFSettings',
reader=reader, data=logic_ports)
response = reader.send(command)
command.pretty_print()
@ -84,7 +85,7 @@ def set_rf_settings_saved(reader):
'AntNb': 0,
}
logic_ports = [logic_port]
command = models.ReaderCommand(command_name='Set_RFSettings_Saved',
command = librfid.ReaderCommand(command_name='Set_RFSettings_Saved',
reader=reader, data=logic_ports)
response = reader.send(command)
command.pretty_print()
@ -95,7 +96,7 @@ def set_rf_settings_saved(reader):
def reset_rf_settings(reader):
print 'Reset_RFSettings'
try:
command = models.ReaderCommand(command_name='Reset_RFSettings',
command = librfid.ReaderCommand(command_name='Reset_RFSettings',
reader=reader)
response = reader.send(command)
command.pretty_print()
@ -107,7 +108,7 @@ def get_health_parameters(reader):
print 'Get_HealthParameters'
quality = ['Disconnected', 'Bad', 'Good']
try:
command = models.ReaderCommand(command_name='Get_HealthParameters',
command = librfid.ReaderCommand(command_name='Get_HealthParameters',
reader=reader)
response = reader.send(command)
command.pretty_print()
@ -147,7 +148,7 @@ def test_5(reader):
get_health_parameters(reader)
if __name__ == '__main__':
reader = models.RFIDReader()
reader = librfid.RFIDReader()
# Detect same tags before and after changing RF parameters
# test_1(reader)
@ -162,4 +163,22 @@ if __name__ == '__main__':
# Do hard reader reboot
# test_3(reader)
test_5(reader)
get_health_parameters(reader)
get_rf_settings(reader)
inventory(reader)
try:
logic_port = {
'ScanDelay': 280,
'PowerAnt': 31,
'AntNb': 0,
}
logic_ports = [logic_port]
command = librfid.ReaderCommand(command_name='Set_RFSettings',
reader=reader, data=logic_ports)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
except Exception, err:
print str(err)
get_rf_settings(reader)
inventory(reader)