Source came through sorta ok....

The basics look good, in terms of address calculations and such.
I don't know what version of TOS you are using so I'm not sure
about the details of the interfaces. The one getPayload() method
I've used expects to get a pointer to a payload size, I think,
rather than the size itself. Also are you sure your message_t
has enough room in it's data for all the structs you overlay?

MS


David wrote:
> I fear the formatting of the source code will be broken when coming out 
> of the mail-list. The actual code is this:
> 
> error_t dsrRouteRequest(am_addr_t destination) {
> message_t rrMessage;                           // The message we will use
> nx_struct dsrPacket* rrPayload;                // A pointer to the 
> messages payload
> nx_struct dsrOptionsHeader* header;            // A pointer to the DSR 
> Header
> nx_struct dsrRouteRequestOption* rrOption;     // A pointer to the DSR 
> Route Request Option
> uint8_t requestPacketLength =                  // Keeps the length of 
> the Route Request Payload which is
>       sizeof(nx_struct dsrOptionsHeader)       // The length of the DSR 
> Options Header +
>     + sizeof(nx_struct dsrRouteRequestOption)  // The length of the DSR 
> Route Request Option -
>     - sizeof(am_addr_t)*MAX_ROUTE_LENGTH;      // The number of 
> addresses we do not use. Since we initiate this Route Request we only 
> need to attach this nodes address to the Request
> 
> 
> error_t err;                                   // Space to store 
> returned error messages
> 
> /*********************************************************************************
> * Create a Route Request Packet                                         
>         *
> ********************************************************************************/
> rrPayload = (nx_struct dsrPacket*) (call Packet.getPayload(&rrMessage, 
> requestPacketLength)); // Get a pointer to the Packets payload
> if(rrPayload==NULL) return FAIL;                                        
>           // If getPayload fails return FAIL, happens when the payload 
> length exceeds the maximum length
> 
> 
> header   = (nx_struct dsrOptionsHeader*) rrPayload;                     
>           // Header points to the first element of the packet's payload
> rrOption = (nx_struct dsrRouteRequestOption*) (((nx_uint8_t*) rrPayload 
> ) + sizeof(nx_struct dsrOptionsHeader)); // RrOption points to the first 
> element in the buffer after the header
> 
> 
> header->nextHeader       = 59;                                          
>           // 59 == No Next Header
> header->flagF            = 0;                                           
>           // Flow State Flag must be 0
> header->reserved         = 0;                                           
>           // Reserved bits must be 0
> header->payloadLength    = sizeof(nx_struct dsrRouteRequestOption) - 
> sizeof(am_addr_t)*MAX_ROUTE_LENGTH; // Length of carried options, which 
> is only the Route Request Option with a single address appended
> 
> rrOption->optionType     = OPTION_TYPE_ROUTE_REQUEST;
> rrOption->optDataLength  = sizeof(nx_uint16_t) + sizeof(am_addr_t)*2;   
>           // OptionType and OptDataLength are not taken into account 
> (RFC4728 p. 41)
> rrOption->identification = routeRequestId++;                            
>           // Take the routeRequestId value as the ID and increment the 
> variable
> rrOption->targetAddress  = destination;                                 
>           // Add the address to which we want to find a route
> rrOption->address[0]     = call AMPacket.address();                     
>           // Add this nodes address to the Route Request Option
> 
> 
> /*********************************************************************************
> * Send the Route Request Packet                                         
>         *
> ********************************************************************************/
> err = call AMSend.send(AM_BROADCAST_ADDR, &rrMessage, requestPacketLength);
> if(err != SUCCESS) return FAIL;
> 
> 
> return SUCCESS;
> }
> 
> The sending node sends its message a couple of times and then crashes 
> and reboots. The crashes do occur even if I out-comment everything 
> between the "Create a Route..." and "Send the Route..." comments (except 
> the getPayload line of course) and set a fixed requestPacketLength. 
> Since there is not really that much code I start wondering whether I'm 
> trying to do something that simply doesn't work this way with TinyOS. I 
> had a lot of debugging messages in this code so I know that the packet 
> is build as expected and send. 
> 
> I've also programmed a little network sniffer node which prints the 
> packets caught onto the pc screen. So I know that the packets are sent 
> correctly since everything arrives as expected at the sniffer node and 
> can be decoded.
> 
> Thanks David.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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