LLRPyC
From EnneEnneWiki
Contents |
| |
Note: Since the code is in Alpha release it's still in high developing stage some information may be incomplete or not well fixed. |
Introduction
Client side of LLRP protocol implementation in python. Core of the project is a library functions which can be used to implement several clients type from simple scripts to command line/graphic clients, etc..
This document gives a quick view of the project, I hope to enhance the documentation with a better and completed document. Help is welcomed! :)
Getting help
This wiki is the main documentation for LLRPyC.
If you need more help, please ask your question on the LLRPyC mailing list and we will try to help you as best we are able.
Getting and installing the code
The latest code is available via git. You can browse the revision control history in your web browser by visiting the LLRPyC gitweb.
Snapshoots of the code can be downloaded from the SourceForge site. Warning, such snapshoots may refer to old code, so please, refer all times to the git repository.
Cloning my repository
To clone my repository use the command:
$ git clone git://git.enneenne.com/llrpyc my-llrpyc-clone
When one of the above commands completes, you will have all the code into the directory my-llrpyc-clone.
Whenever new patches are added to my repository, you can update your repository by giving the following commands:
$ cd my-llrpyc-clone $ git pull
Installing the code
Since the code is written in python you simply have to install it without compiling anything. Just chdir into my-llrpyc-clone directory and give the command:
$ make install
after that you are ready to use the new package.
Application and example programs
Into directory clients are stored some applications or example programs which use LLRPyC package. In each directory you'll find a README file which hold a brief description and program usage.
Quick reference/usage
Server connection
In order to use this package you simply have to import it into your program as follow:
from llrp_proto import *
after that you can create a connection with a LLRP server by using the following code:
print 'connecting with remote server...'
try:
server = LLRPdConnection(host, event_cb = print_event)
except LLRPResponseError, ret:
print 'fail: %s (code=%s)' % (ret.descr, ret.code)
else:
print 'done'
into "server" variable you'll get on object describing the LLRP connection which can be used for later server queries.
The "print_event" is a function which is called each time the server send us an event message. Function LLRPdConnection() has also the parameter "port" which is set by default to 5084.
Once you have finished with current server you can close the connection with the close() method as follow:
server.close()
Server capabilities
To get server capabilities you can use method get_capabilities() as follow:
print 'asking for reader capabilities... '
try:
cap = server.get_capabilities('LLRP Capabilities')
except LLRPResponseError, ret:
sys.exit(1)
print 'done'
print 'capabilities are:'
print cap
as argument the function takes one of the following string: 'All', 'General Device Capabilities', 'LLRP Capabilities', 'Regulatory Capabilities', 'Air Protocol LLRP Capabilities' and returns a capability object which can be easily printed with python print function.
ROSpec
In order to create a ROSpec into the server you can use the function LLRPROSpec() and then execute the add() method:
rospec = LLRPROSpec(123)
print 'enabling ROSpec... '
try:
rospec.enable(server)
except LLRPResponseError, ret:
sys.exit(1)
else:
print 'done'
Value 123 is the ROSpec ID but you can also specify the ROSpec priority in [0,7] (0 by default) and the ROSpec's state ('Disabled' by default).
By default the just created ROSpec has null triggers and enable all antennae (see code for further info). Currently there are no functions to modify these settings.
Note that you can enable the save ROSpec into several servers simply changing the connection object:
rospec.enable(server1) rospec.enable(server2) rospec.enable(server3)
A ROSpec object has also other methods to manage a ROSpec into a reader:
rospec.add(server) rospec.delete(server) rospec.disable(server) rospec.start(server) rospec.stop(server)
You can use connection object's method delete_all_rospec() to delete all ROSpec in a reader at once:
print 'deleting all existing ROSpecs... '
try:
server.delete_all_rospec()
except LLRPResponseError, ret:
sys.exit(1)
print 'done'
