On Saturday 31 January 2009 16:37:30 ricardo lafuente wrote:
> Mine's on the way -- this lurker sends a huge thank you.
You're welcome. I've started playing with mine, and this code here...
https://projects.nesl.ucla.edu/view/viewcvs.cgi/tikitag/trunk/pytiki/
... is probably the simplest interface to the tags. (simple meaning not
full featured of course, but minimally sufficient IMO). The base example
it comes with is this:
import pytiki as ti
ti.tiki_init()
ti.tiki_config(5000,0)
for i in range(100):
num = ti.tiki_seek()
if num == 0:
print "No tag found"
elif num == 1:
print "%x"%ti.tiki_getID1()
elif num == 2:
print "%x"%ti.tiki_getID1()
print
print "%x"%ti.tiki_getID2()
else:
print "Nope"
ti.tiki_close()
Which is relatively trivial to componentise:
import pytiki as ti
class TikiTagReader(Axon.ThreadedComponent.threadedcomponent):
def main(self):
try:
ti.tiki_init()
ti.tiki_config(5000,0)
while not self.dataReady("control"):
num = ti.tiki_seek() # blocking operation
if num == 0:
self.send( "notag", "outbox")
elif num == 1:
self.send( ("tags", [ ti.tiki_getID1()] ), "outbox")
elif num == 2:
self.send( ("tags", [ ti.tiki_getID1(), ti.tiki_getID2() ]
) , "outbox")
else:
print "error"
finally:
ti.tiki_close()
It's worth noting that this will spit out *alot* of messages, so it would
probably be a better idea to change this to a component that looks for
*changes* and passes on changes to the next one, but that would look
a little more (though not much more!) complex.
Naturally then it's simple to interface this to any other component...
Regards,
Michael
--
http://yeoldeclue.com/blog
http://twitter.com/kamaelian
http://www.kamaelia.org/Home
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"kamaelia" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---