Hi everybody, I am trying to use python sdk to communicate with Serial Forwarder. I receive messages using "receive(self, src, msg)" as in Chad's example and it works ok. However I found some troubles when trying to send messages to Serial Forwarder.
I guess I should use MoteIF's "sendMsg(self, dest, addr, amType, group, msg)" method. I have tried the following call in my class: self.mif.sendMsg(self.source, 0, t.get_amType(), 0, t) Where, self.source = self.mif.addSource("[EMAIL PROTECTED]:9002") and t=TestSerialMsg() t.set_counter(13) But I get the following errors: (32, 'Broken pipe') File "/opt/tinyos-2.x/support/sdk/python/tinyos/message/MoteIF.py", line 124, in sendMsg dest.writePacket(data) File "/opt/tinyos-2.x/support/sdk/python/tinyos/packet/SFSource.py", line 69, in writePacket self.prot.writePacket(packet) File "/opt/tinyos-2.x/support/sdk/python/tinyos/packet/SFProtocol.py", line 74, in writePacket self.outs.write(chr(len(packet))) File "/opt/tinyos-2.x/support/sdk/python/tinyos/packet/SocketIO.py", line 77, in write return self.socket.send(data) None What am I doing wrong? Am I using the correct method? Thanks in advance, Iñigo On 9/14/07, Chad Metcalf <[EMAIL PROTECTED]> wrote: > 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 > > Tinyos-help@Millennium.Berkeley.EDU > > > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > > > > > > -- > Chad @ Home > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@Millennium.Berkeley.EDU > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help