It should work with any of the tools (Java, C, or C++ SFs). When it comes to
MoteIF you'll find them very similar.
Using TestSerial as an example:
--- Makefile ---
COMPONENT=TestSerialAppC
BUILD_EXTRA_DEPS += TestSerial.class TestSerialMsg.py
CLEAN_EXTRA = *.class TestSerialMsg.java TestSerialMsg.py
TestSerial.class: $(wildcard *.java) TestSerialMsg.java
javac *.java
TestSerialMsg.java:
mig java -target=null $(CFLAGS) -java-classname=TestSerialMsg
TestSerial
.h test_serial_msg -o $@
TestSerialMsg.py:
mig python -target=null $(CFLAGS) -python-classname=TestSerialMsg
TestSe
rial.h test_serial_msg -o $@
include $(MAKERULES)
-----
--- example.py ---
#!/usr/bin/env python
# This is a quick and dirty example of how to use the MoteIF interface in
# Python
from TestSerialMsg import *
from tinyos.message import MoteIF
class MyClass:
def __init__(self):
# Create a MoteIF
self.mif = MoteIF.MoteIF()
# Attach a source to it
self.source = self.mif.addSource("[EMAIL PROTECTED]:9001")
# SomeMessageClass.py would be generated by MIG
self.mif.addListener(self, TestSerialMsg)
# Called by the MoteIF's receive thread when a new message
# is received
def receive(self, src, msg):
print "Received message: "+ str(msg)
if __name__ == "__main__":
print "Running"
m = MyClass()
----
Not terribly useful example but it works.
Cheers
Chad
On 9/14/07, John Griessen <[EMAIL PROTECTED]> wrote:
>
> Matt Welsh wrote:
> > We've developed a Python based SDK for TinyOS, allowing you to write
> > Python programs that talk to serialforwarder, send and receive packets,
> > and so forth.
>
> Sounds great. I've been using the c++ serial forwarder. Has it been
> tested with that yet? Does it parallel the whole java process of
> making message classes?
>
> Might it be just changing .java to .py
> in a Makefile like:
>
> ==========================
> COMPONENT=ReadMoistureSensorsC
> SENSORBOARD=a2d12ch
>
> BUILD_EXTRA_DEPS=MoistureSensorsMsg.class
> MoistureSensorsMsg.class: MoistureSensorsMsg.java
> javac MoistureSensorsMsg.java
>
> MoistureSensorsMsg.java:
> mig java -target=null -java-classname=MoistureSensorsMsg
> ReadMoistureSensors.h MoistureSensorsMsg -o $@
>
> include $(MAKERULES)
> ===============================
>
> Thanks,
>
> John Griessen
> --
> Ecosensory
> tinyOS devel on: ubuntu Linux; tinyOS v2.0.2; telosb ecosens1
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
--
Chad @ Home
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help