tinyos / tinyos-main

Main development repository for TinyOS (an OS for embedded, wireless devices).
1.41k stars 519 forks source link

SDK: Python: tinyos.packet.telos missing #249

Open salkinium opened 10 years ago

salkinium commented 10 years ago

Trying to open a serial connection via the python sdk on a telos mote fails.

self.mif = MoteIF.MoteIF()
self.tos_source = self.mif.addSource("serial@/dev/ttyUSB0:telos")

The failure happens because in packet/Platform.py:83 the tinyos.packet.telos is tried to be imported, but since only tinyos.packet.avrmote is available, this fails.

mod = __import__("tinyos.packet.%s" % platform)
return mod.packet.__dict__[platform].TOS_Msg

I can change the look-up table to say avrmote instead of telos, but I assume there is a good reason (ie. 8 vs. 16 bit processor) that they are different:

PLATFORMS = {"mica": ("avrmote", 1, 19200),
             "mica2dot": ("avrmote", 1, 19200),
             "mica2": ("avrmote", 1, 57600),
             "telos": ("telos", 2, 57600),
             "tmote": ("telos", 2, 57600),
             "micaz": ("avrmote", 3, 57600),
             "eyes": ("eyes", 4, 19200)}

Any idea why tinyos.packet.telos is missing, and what it should be? Is it supposed to be generated by mig? (If so, why is it avrmote.py checked in, but not telos.py?)

Update: I think there is no reason why the avrmote.py should not work on other platforms as well. It does on the TelosB.

Update2: The baudrate of the telos is also false, the default is 115200 (/tos/lib/platforms/telosa/TelosSerialP.nc).

As far as I am concerned, this quickfix solves this issue:

PLATFORMS = {"mica": ("avrmote", 1, 19200),
             "mica2dot": ("avrmote", 1, 19200),
             "mica2": ("avrmote", 1, 57600),
             "telos": ("avrmote", 2, 115200),
             "tmote": ("avrmote", 2,115200),
             "micaz": ("avrmote", 3, 57600),
             "eyes": ("eyes", 4, 19200)}
phil-levis commented 10 years ago

Can you generate a proper telos packet with mig?

salkinium commented 10 years ago

Actually, I think this is a relic from TinyOS 1.x. According to TEP111, the TOS_Msg was replaced by the more generic message_t struct with (header, data, footer, metadata) starting with TinyOS 2.x.

Also, the only place this table is accessed is in packet/SerialSource.py, to get the baudrate (which is wrong, btw) and the factory (=TOS_Msg). However, the SerialSource.factory is never used for anything else.

So the python SDK is a little stuck somewhere between 1.x and 2.x.

salkinium commented 10 years ago

To take the blow out of that last sentence: Apart from this little mishap the rest seems to be working fine :-)