Closed edmondhk closed 4 years ago
Hello,
I am not sure I fully understood your issue.
Check out the attribute start_inventory
of the LLRPReaderConfig
in sllurp/llrp.py file.
It is set to True
by default. It means the scan (I assume you mean the inventory) will start automatically after opening connection with the reader.
Check out the line 105 of this commit: https://github.com/fviard/sllurp/pull/4/commits/5ea181b6925b1e23e9cf286e2f80ad8cb829a82e I wrapped sllurp within a class.
Yes, as explained by @papapel , the "connect()" call both connect to the reader, and initiate the inventory immediately.
Similarly, you use disconnect to stop the inventory and that will disconnect from the reader at the same time.
That is not too great, but at the moment, sllurp is a big state machine, and working like that ensure to only hold a connection to a reader when we are using it.
As an additional example, you can have a look at how the inventory is performed with the "sllurp" cli: https://github.com/fviard/sllurp/blob/develop_untwisted_next/sllurp/verb/inventory.py
And btw, maybe you have misunderstood the meaning of the "join":
Yes, as explained by @papapel , the "connect()" call both connect to the reader, and initiate the inventory immediately.
Similarly, you use disconnect to stop the inventory and that will disconnect from the reader at the same time.
That is not too great, but at the moment, sllurp is a big state machine, and working like that ensure to only hold a connection to a reader when we are using it.
As an additional example, you can have a look at how the inventory is performed with the "sllurp" cli: https://github.com/fviard/sllurp/blob/develop_untwisted_next/sllurp/verb/inventory.py
And btw, maybe you have misunderstood the meaning of the "join":
* When you connect, the inventory starts and will work alone asynchronously * So, that means that your main loop/code, will continue immediately after this is started. * If you have nothing else in your code, you will reach the end of your script, and your program will exit alone, as the reader thread is running in the background * So, the "join" is kind of a "wait indefinitely until the reader is disconnected or connection lost". That is it's only purpose.
Thank you and @papapel . Good to know it is completely normal I guess I will add a little "switch" in my class to switch "on" the callback function or just skip it. As my application is pretty static, which just need to do inventory for 1 sec after receiving the
BTW. @fviard is right, I misunderstand the join function because of this.
try:
# Block forever or until a disconnection of the reader
reader.join(None)
except (KeyboardInterrupt, SystemExit):
# catch ctrl-C and stop inventory before disconnecting
reader.disconnect()
I pack the reader logic in a class so my project is like UI -RFID.py(The class) Call sllurp here
When I create the RFID class, it start to scan already, before I call the join which I comment out while debugging.
Here is my testing code UI:
RFID.py: