From: prabal Date: Wed, 17 Jan 2007 20:26:08 +0000 (+0000) Subject: Minor edits and corrections X-Git-Tag: tinyos/2.0.1~224 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=2a0b325aef5b520dcb7244f0a0fe5b55cb04e08d;p=tinyos-2.x.git Minor edits and corrections --- diff --git a/doc/html/tutorial/lesson3.html b/doc/html/tutorial/lesson3.html index 09637e0a..c0d5a35d 100644 --- a/doc/html/tutorial/lesson3.html +++ b/doc/html/tutorial/lesson3.html @@ -408,31 +408,34 @@ structures, this syntax should look familar but the nx_ prefix on the keywords struct and uint16_t should stand out. The nx_ prefix is specific to the nesC language and signifies that the struct and uint16_t are -external types(3)(4). -External types have the same representation on all platforms. - The nesC compiler generates code that transparently reorders access to - nx_ data types and eliminates the need to manually address -endianness and alignment (extra padding in structs present on some -platforms) issues. So what is endianness? Read on... +external types(3)(4). External types have the same representation +on all platforms. The nesC compiler generates code that transparently +reorders access to nx_ data types and eliminates the need +to manually address endianness and alignment (extra padding in structs +present on some platforms) issues. So what is endianness? Read on...

Different processors represent numbers in different ways in their -memory: some processors use a "big endian" representation which -means that the most significant byte of a multi-byte (e.g. 16- or -32-bit) number is located at a lower memory address than the least -significant byte, while "little endian" stores data in exactly the -opposite order. A problem arises when data is serialized and sent -over the network because different processors will decode the same set -of bytes in different ways, depending on their "endianness." The -main difficulty endiannes presents is that it requires operations to -rearrange byte orders to match the network protocol specification or -the processor architecture -- an annoying and error-prone process. -The htons, htonl, ntohs, and ntohl -calls used with the sockets API are an example of platform-specific -calls that convert between network and host byte orders, but you have -to remember to use them. The nesC programming language takes a -different approach to the problem and defines -external types which allow the programmer to avoid dealing with byte -reordering. +memory: some processors use a "big endian" representation which means +that the most significant byte of a multi-byte (e.g. 16- or 32-bit) +number is located at a lower memory address than the least significant +byte, while "little endian" stores data in exactly the opposite order. +A problem arises when data is serialized and sent over the network +because different processors will decode the same set of bytes in +different ways, depending on their "endianness." The main difficulty +endianness presents is that it requires operations to rearrange byte +orders to match the network protocol specification or the processor +architecture -- an annoying and error-prone process. The +htons, htonl, ntohs, and +ntohl calls used with the sockets API are an example of +platform-specific calls that convert between network and host byte +orders, but you have to remember to use them. The nesC programming +language takes a different approach to the problem and defines +external types which allow the programmer to avoid dealing with +byte reordering. In particular, the nx_ prefix on a type +(e.g. nx_uint16_t) indicates the field is to serialized +in big endian format. In contrast, the nxle_ prefix +signifies that the field is serialized in little endian format.

Sending a Message

@@ -531,7 +534,7 @@ declarations need to be added in the implementation block of
 implementation {
   bool busy = FALSE;
-  message_t packet;
+  message_t pkt;
   ...
 }
 
@@ -557,8 +560,9 @@ the following body: } -

We also need to implement the AMControl.startDone event -handler, which has the following body: +

We also need to implement the AMControl.startDone and +AMControl.stopDone event handlers, which have the +following bodies:

   event void AMControl.startDone(error_t err) {
@@ -569,6 +573,9 @@ handler, which has the following body:
       call AMControl.start();
     }
   }
+
+  event void AMControl.stopDone(error_t err) {
+  }
 

If the radio is started successfully, AMControl.startDone @@ -782,7 +789,7 @@ interfaces we plan on using.

We need to implement the

 event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
   if (len == sizeof(BlinkToRadioMsg)) {
-    BlinkToRadioMsg* btrmsg = (BlinkToRadioMsg*)payload;
+    BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
     call Leds.set(btrpkt->counter);
   }
   return msg;