________________________________
From: Romain Bornet <[email protected]>
To: TJ <[email protected]>
Cc: [email protected]
Sent: Wednesday, July 13, 2011 8:15 AM
Subject: Re: [Tinyos-help] Message structure in MicaZ on Ubuntu
 
Hi,

Sorry but I have no experience with TinyOS 1.1 and MoteWorks but...

>>  I couldn't install TinyOS 2.1.1 on my Ubuntu OS, and hence I'm stuck 
>>programming it on MoteWorks.
Micaz is one of the best supported platform in TinyOS 2.1.1 and there
are existing packages and/or possible manual install steps to get
TinyOS 2.1.1 on Ubuntu. I think it would be worth to work on the
latest code base.

- Try these steps to install TinyOS 2.1.1 on Ubuntu...

- Install most recent jdk6: 

sudo gedit /etc/apt/sources.list 

- Uncomment the following two lines 

deb http://archive.canonical.com/ubuntu natty partner 
deb-src http://archive.canonical.com/ubuntu natty partner 

- Update the repositories and install java:

sudo apt-get update 
sudo apt-get install sun-java6-jdk 

- Add TinyOS 2 repository to apt-get

sudo vim /etc/apt/sources.list 

- Add the following line 

deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main 

sudo apt-get update 
sudo apt-get install tinyos-2.1.1 

- Add the following lines to ~/.bashrc

source /opt/tinyos-2.1.1/tinyos.sh 
export PATH=/usr/lib/jvm/java-6-sun-1.6.0.XX/bin:$PATH 
export CLASSPATH=.:/opt/tinyos-2.1.1/support/sdk/java/tinyos.jar:$CLASSPATH 

- Open a new Terminal and run the following command to make sure everything is 
OK 

tos-check-env 

- Change permissions and install g++ 

sudo chmod -R 777 /opt/tinyos-2.1.1/ 
sudo apt-get install g++ 

- Recompile the java code 

cd /opt/tinyos-2.1.1/support/sdk/java/net 
make clean 
cd .. 
make tinyos.jar 
sudo tos-install-jni 

- Try the Blink app

cd /opt/tinyos-2.1.1/apps/Blink 
make micaz install mib510,/dev/ttyS0 

- Try the Listen java app 

cd /opt/tinyos-2.1.1/support/sdk/java/net/tinyos/tools 
javac Listen.java 
export MOTECOM=serial@COM1:micaz 
java net.tinyos.tools.Listen 

- IN CASE you still have a versioning problem with java, install Java SE 5
 and move it to /usr/lib/jvm then repeat all previous steps. Download 
the .bin from Here 

cd ~/Downloads 
sudo chmod 775 jdk-1_5_0_22-linux-amd64.bin 
sudo ./jdk-1_5_0_22-linux-amd64.bin 
sudo mv ~/Downloads/jdk1.5.0_22 /usr/lib/jvm 
sudo rm jdk-1_5_0_22-linux-amd64.bin 

Hope this helps,
- GA

> The code i used to get the raw data is attached. It's based on 
> arduino-serial.c that i found online. This was the only option i had, as i 
> needed a program to read and write to USB without the java packages coming 
> in, as it does in SerialForwarder. Also, My mote doesn't react when i send 
> back the same string through the USB.

With your code, you can apparently get the messages from your mote.
This already works (even if the format is most probably the one I
described in my last email). To manually send packets to your mote,
you'll have to know more precisely what is the format of the packets
to build them correctly and to check that the application running on
your mote is effectively listening to incoming packets. For this, you
have to go through the code of your "MoteWorks flavor" of TinyOS and
understand how packets are built. You must also have a look at the
application code to see if it listens to incoming packets.

By simply sending back the same string I can imagine following issues
(only suppositions):
1. Dest and Source address should be exchanged otherwise the
destination won't recognize the packet as a valid one (dest address !=
mote address)$
2. If some fields are changed in the packet the CRC must be computed
again on the new data and cannot be copied "as is" from the incoming
packet otherwise the target will detect a wrong CRC.

Hope this helps,
    Romain

On Wed, Jul 13, 2011 at 11:11 AM, TJ <[email protected]> wrote:
> Hey
> Thanks for the quick reply.
>
> The raw data is from MicaZ running a program written in MoteWorks. It is
> based on TinyOS-1.x I think.
> I couldn't install TinyOS 2.1.1 on my Ubuntu OS, and hence I'm stuck
> programming it on MoteWorks.
>
> The code i used to get the raw data is attached. It's based on
> arduino-serial.c that i found online.
> This was the only option i had, as i needed a program to read and write to
> USB without the java packages coming in, as it does in SerialForwarder.
> Also, My mote doesn't react when i send back the same string through the
> USB. And i'm clueless as to why. Can you help??
>
>
> And I will go through the TEP, thank you.
>
>
> Always Yours
> Tejovanth
> Tj n Spook
>
>
> On Wed, Jul 13, 2011 at 1:28 PM, Romain Bornet <[email protected]>
> wrote:
>>
>> Hi,
>>
>> Have a look at TEP 113: Serial Communication
>> In section 3.6 Packet Format the layout of the bytes is explained.
>>
>> What you see is the "raw" frame at the lowest level of the serial
>> stack. It is encoded in a HDLC-like way.
>> In your case the frame 7e 42 7d 5e 00 00 7d 5d 04 01 00 96 00 1c 32 7e
>> can be split into:
>>
>> -- HDLC header
>> 7e HDLC framing byte (start of frame)
>> 42 Protocol byte (0x42 = 66 -> )
>> 7d HDLC escape character because next byte should be '7e'
>> 5e Sequence number
>>
>> -- Payload = Active Message
>> 00 00 7d 5d 04 01 00 96 00  (here again there is an HDLC escape
>> character 7d....)
>>
>> Payload "HDLC decoded" = 00 00 7d 04 01 00 96 00
>> According to the serial_header_t in Serial.h of the latest TinyOS this
>> would correspond to:
>> 00 00 dest
>> 7d 04 source
>> 01 length
>> 00 AM group
>> 96  AM Type
>> 00  1 byte Data
>>
>> -- HDLC footer
>> 1c 16 bits CRC high byte
>> 32 16 bits CRC low byte
>> 7e HDLC framing byte (end of frame)
>>
>> The Payload seems strange to me... Which version of TinyOS are you
>> using ? How do you test ? With a standard application or one you wrote
>> yourself ?
>>
>> I suggest you to have a look at the TEPs mentioned above and in
>> sources found in your TinyOS source tree under lib/serial .
>>
>> Regards
>>    Romain
>>
>> On Wed, Jul 13, 2011 at 7:32 AM, TJ <[email protected]> wrote:
>> > Hey.
>> >
>> > I get the following line in hex (similar to this) when i receive a
>> > packet
>> > from the MicaZ mote on Ubuntu.
>> > 7e 42 7d 5e 00 00 7d 5d 04 01 00 96 00 1c 32 7e
>> >
>> > I'm not really sure on what the all the numbers are, except that the one
>> > in
>> > red is the node id, and one in green is a count. This I know because of
>> > the
>> > structure i put in.
>> >
>> > If my program sends the same line from the PC to the mote, will the mote
>> > understand it??
>> >
>> > Always Yours
>> > Tejovanth
>> > Tj n Spook
>> >
>> > _______________________________________________
>> > Tinyos-help mailing list
>> > [email protected]
>> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>> >
>
>

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to