If you look in the "provides" it says that it includes ReceiveMsg as Receive
but there isn't any Receive command provided in it's code.  So I just pasted
the default event from FramerM:
  default event TOS_MsgPtr Receive.receive(TOS_MsgPtr Msg) {
    return Msg;
  }

I still get the same error message.  Argh!  All the code is pasted at the
bottom.

/*
 * Copyright (c) 2002-2005 Intel Corporation
 * Copyright (c) 2000-2005 The Regents of the University of California
 * All rights reserved.
 * See license.txt file included with the distribution.
 *
 * $Id: NoCRCPacket.nc,v 1.1.4.1 2007/04/27 06:02:00 njain Exp $
 */


/*
 *
 * Authors:             Jason Hill, Alec Woo, David Gay, Philip Levis
 * Date last modified:  6/25/02
 *
 */

/* This component handles the packet abstraction on the network stack 
*/

/**
 * @author Jason Hill
 * @author Alec Woo
 * @author David Gay
 * @author Philip Levis
 */

module NoCRCPacket {
  provides {
    interface StdControl as Control;
    interface BareSendMsg as Send;
    interface ReceiveMsg as Receive;
    interface SendVarLenPacket;

    command result_t txBytes(uint8_t *bytes, uint8_t numBytes);
    /* Effects: start sending 'numBytes' bytes from 'bytes'
    */
  }
  uses {
    interface ByteComm;
    interface StdControl as ByteControl;
    interface Leds;
  }
}
implementation
{
  uint8_t rxCount, rxLength, txCount, txLength;
  TOS_Msg buffers[2];
  TOS_Msg* bufferPtrs[2];
  uint8_t bufferIndex;
  uint8_t *recPtr;
  uint8_t *sendPtr;
  
  enum {
    IDLE,
    PACKET,
    BYTES
  };
  uint8_t state;

  /*
    state == IDLE, nothing is being sent
    state == PACKET, this level is sending a packet
    state == BYTES, this level is just transferring bytes

    The purpose of adding the new state, to simply transfer bytes, is
because
    certain applications may want to just send a sequence of bytes without
the
    packet abstraction.  One such example is the UART.

   */
  

  /* Initialization of this component */
  command result_t Control.init() {
    atomic {
      recPtr = (uint8_t *)&buffers[0];
      bufferIndex = 0;
      bufferPtrs[0] = &buffers[0];
      bufferPtrs[1] = &buffers[1];
      
      state = IDLE;
      txCount = rxCount = 0;
      // make sure we always read up to the type (which determines length)
      rxLength = offsetof(TOS_Msg, type) + 1;
      dbg(DBG_BOOT, "Packet handler initialized.\n");
    }
    return call ByteControl.init();
  }

  /* Command to control the power of the network stack */
  command result_t Control.start() {
    // apply your power management algorithm
    return call ByteControl.start();
  }

    /* Command to control the power of the network stack */
  command result_t Control.stop() {
    // apply your power management algorithm
    return call ByteControl.stop();
  }

  command result_t txBytes(uint8_t *bytes, uint8_t numBytes) {
    uint8_t byteToSend = 0;
    bool sending = FALSE;
    atomic {
      if (txCount == 0)
        {
          txCount = 1;
          txLength = numBytes;
          sendPtr = bytes;
          byteToSend = sendPtr[0];
          sending = TRUE;
        }
    }
    if (sending) {
      /* send the first byte */
      if (call ByteComm.txByte(byteToSend))
        return SUCCESS;
      else {
        atomic {
          txCount = 0;
        }
      }
    }
    return FAIL;
  }
  
  /* Command to transmit a packet */
  command result_t Send.send(TOS_MsgPtr msg) {
    uint8_t oldState;
    uint8_t* packet;
    uint8_t sendNum;
    result_t rval = FAIL;
    atomic {
      oldState = state;
      if (state == IDLE) {
        state = PACKET;
      }
      packet = (uint8_t*)msg;
      sendNum = TOS_MsgLength(msg->type);
    }
    if (oldState == IDLE) {
      atomic {
        msg->crc = 1; /* Fake out the CRC as passed. */
        rval = call txBytes(packet, sendNum);
      }
    }
    return rval;
  }

  /* Command to transfer a variable length packet */
  command result_t SendVarLenPacket.send(uint8_t* packet, uint8_t numBytes)
{
    uint8_t oldState;
    result_t rval = FAIL;
    atomic {
      oldState = state;
      if (state == IDLE) {
        state = BYTES;
      }
    }
    if (oldState == IDLE) {
      atomic {
        rval = call txBytes(packet, numBytes);
      }
    }
    return rval;
  }

  
  task void sendDoneFailTask() {
    TOS_MsgPtr msg;
    atomic {
      txCount = 0;
      state = IDLE;
      msg = (TOS_MsgPtr)sendPtr;
    }
    signal Send.sendDone(msg, FAIL);
  }
  
  task void sendDoneSuccessTask() {
    TOS_MsgPtr msg;
    atomic {
      txCount = 0;
      state = IDLE;
      msg = (TOS_MsgPtr)sendPtr;
    }
    signal Send.sendDone(msg, SUCCESS);
  }

  task void sendVarLenFailTask() {
    uint8_t* buf;
    atomic {
      txCount = 0;
      state = IDLE;
      buf = sendPtr;
    }
    signal SendVarLenPacket.sendDone(buf, FAIL);
  }

  task void sendVarLenSuccessTask() {
     uint8_t* buf;
    atomic {
      txCount = 0;
      state = IDLE;
      buf = sendPtr;
    }
    signal SendVarLenPacket.sendDone(buf, SUCCESS);
  }
  
  void sendComplete(result_t success) {
    uint8_t stateCopy;
    atomic {
      stateCopy = state;
    }

    if (stateCopy == PACKET) {

      /* This is a non-ack based layer */
      /* This seems wrong to me -- it assumes this is
         on top of the UART (a non-ack based layer). What
         if we want to send a NoCrcPacket over the radio? -pal */
      if (success) {
        TOS_MsgPtr msg;
        atomic {
          msg = (TOS_MsgPtr)sendPtr;
          msg->ack = TRUE;
        }
        post sendDoneSuccessTask();
      }
      else {
        post sendDoneFailTask();
      }
    }
    else if (stateCopy == BYTES) {
      if (success) {
        post sendVarLenSuccessTask();
      }
      else {
        post sendVarLenFailTask();
      }
    }
    else {
      atomic {
        txCount = 0;
        state = IDLE;
      }
    }
  }

      
  default event result_t SendVarLenPacket.sendDone(uint8_t* packet, result_t
success) {
    return success;
  }

  default event result_t Send.sendDone(TOS_MsgPtr msg, result_t success){
    return success;
  }
  
  
  /* Byte level component signals it is ready to accept the next byte.
     Send the next byte if there are data pending to be sent */
  async event result_t ByteComm.txByteReady(bool success) {
    uint8_t txC;
    uint8_t txL;
    atomic {
      txC = txCount;
      txL = txLength;
    }
    if (txC > 0) {
      if (!success) {
        dbg(DBG_ERROR, "TX_packet failed, TX_byte_failed");
        sendComplete(FAIL);
      }
      else if (txC < txL) {
        uint8_t byteToSend;
        atomic {
          byteToSend = sendPtr[txC];
          txCount++;
        }
        dbg(DBG_PACKET, "PACKET: byte sent: %x, COUNT: %d\n",
            sendPtr[txCount], txCount);
        if (!call ByteComm.txByte(byteToSend))
          sendComplete(FAIL);
      }
    }
    return SUCCESS;
  }

  async event result_t ByteComm.txDone() {
    bool complete;
    atomic {
      complete = (txCount == txLength);
    }
    if (complete)
      sendComplete(TRUE);
    return SUCCESS;
  }


  task void receiveTask() {
    TOS_MsgPtr tmp;
    atomic {
      tmp = bufferPtrs[bufferIndex ^ 1];
      //fake out crc
      tmp->crc = 1;
    }
    tmp  = signal Receive.receive(tmp);
    if (tmp) {
      atomic {
        bufferPtrs[bufferIndex ^ 1] = tmp;
      }
    }
  }
  
  default event TOS_MsgPtr Receive.receive(TOS_MsgPtr Msg) {
    return Msg;
  }
  
  /* The handles the latest decoded byte propagated by the Byte Level
     component*/
  async event result_t ByteComm.rxByteReady(uint8_t data, bool error,
                                      uint16_t strength) {
    bool rxDone;

    dbg(DBG_PACKET, "PACKET: byte arrived: %x, COUNT: %d\n", data, rxCount);
    if (error)
      {
        atomic {
          rxCount = 0;
        }
        return FAIL;
      }
    atomic {
      if (rxCount == 0)
        ((TOS_MsgPtr)(recPtr))->strength = strength;
      
      if (rxCount == offsetof(TOS_Msg, type))
        rxLength = TOS_MsgLength(data);
      
      recPtr[rxCount++] = data;

      rxDone = (rxCount == rxLength);
    }
    
    if (rxDone)
      {
        atomic {
          bufferIndex = bufferIndex ^ 1;
          recPtr = (uint8_t*)bufferPtrs[bufferIndex];
          
          dbg(DBG_PACKET, "got packet\n");  
          rxCount = 0;
        }
        post receiveTask();
        return FAIL; 
      }

    return SUCCESS;
  }

}

/*
 * Copyright (c) 2004-2007 Crossbow Technology, Inc.
 * All rights reserved.
 * See license.txt file included with the distribution.
 *
 * $Id: MyApp.nc,v 1.1.2.2 2007/04/26 19:59:29 njain Exp $
 */

 
includes displayUnitCmd;

/**
 * This module shows how to use the Timer, LED, ADC and Messaging
components.
 * Sensor messages are sent to the serial port
 **/
configuration MyApp {
  provides {
        command result_t txBytes(uint8_t *bytes, uint8_t numBytes);
  }
}
implementation {
  components Main, MyAppM, TimerC, LedsC, NoCRCPacket as NoPacket, UART;
  
  Main.StdControl -> TimerC.StdControl;
  Main.StdControl -> MyAppM.StdControl;
  Main.StdControl -> NoPacket.Control;
  
  MyAppM.Timer -> TimerC.Timer[unique("Timer")];
  MyAppM.Leds -> LedsC.Leds;
  
  txBytes = NoPacket.txBytes;
  
  NoPacket.ByteControl -> UART;
  NoPacket.ByteComm -> UART;

}

/*
 * Copyright (c) 2004-2007 Crossbow Technology, Inc.
 * All rights reserved.
 * See license.txt file included with the distribution.
 *
 * $Id: MyAppM.nc,v 1.1.2.4 2007/04/26 19:59:38 njain Exp $
 */

includes displayUnitCmd;

/**
 * This module shows how to use the Timer, LED, ADC and Messaging components
 * Sensor messages are sent to the serial port
 *
 **/
module MyAppM {
  provides {
    interface StdControl;
        
  }
  uses {
    interface Timer;
    interface Leds;
        interface StdControl as PhotoControl;
        interface SendUART;
        
        command result_t txBytes(uint8_t *bytes, uint8_t numBytes);
//      interface SendData;
  }
}
implementation {
  bool sending_packet = FALSE;

  
  /**
   * Initialize the component.
   * 
   * @return Always returns <code>SUCCESS</code>
   **/
  command result_t StdControl.init() {
    call Leds.init(); 


    return SUCCESS;
  }
 

  /**
   * Start things up.  This just sets the rate for the clock component.
   * 
   * @return Always returns <code>SUCCESS</code>
   **/
  command result_t StdControl.start() {
    // Start a repeating timer that fires every 1000ms
    return call Timer.start(TIMER_REPEAT, 1000);
  }

  /**
   * Halt execution of the application.
   * This just disables the clock component.
   * 
   * @return Always returns <code>SUCCESS</code>
   **/
  command result_t StdControl.stop() {
    return call Timer.stop();
  }

  /**
   * Toggle the red LED in response to the <code>Timer.fired</code> event.  
   * Start the Light sensor control and sample the data
   *
   * @return Always returns <code>SUCCESS</code>
   **/
  event result_t Timer.fired()
  {
    call Leds.redToggle();
        
        if (sending_packet) return;
    atomic sending_packet = TRUE;
    
        // send message to UART (serial) port
        if (call txBytes((uint8_t *)0x41,(uint8_t *)0x01) != SUCCESS)
          sending_packet = FALSE;
          
    return SUCCESS;
  }


}






-----Original Message-----
From: Michael Schippling [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 18, 2008 10:27 AM
To: Mark Tsang
Cc: tinyos-help@millennium.berkeley.edu
Subject: Re: [Tinyos-help] Utilizing a command from another module,

I'm not the best at config issues, but it seems that something in
NoCRCPacket expects to have a callout function named receive() which
you need to implement when using the module. Maybe one of the nesc
experts can provide an opinion if you attach all your code and error
messages.

MS


Mark Tsang wrote:
> Exactly, I know that I'm able to call txBytes from my own code but I can't
> seem to get it to work because of the error about a connection from within
> NoCRCPacket explained below:  I've searched the documents for areas
> regarding "calling a command from another module" but no luck.  Aside from
> this being my 14th hour working on this project, could you please at least
> direct me to the proper documentation that would explicitly explain the
> syntax to make this command call.  Thanks!  I'm starting to run out of
> ideas.
> 
>  In component `NoCRCPacket':
> 
>  /opt/MoteWorks/tos/platform/micaz/NoCRCPacket.nc: In function
>  `receiveTask':
>  /opt/MoteWorks/tos/platform/micaz/NoCRCPacket.nc:306: Receive.receive 
>  not connected
> 
> -----Original Message-----
> From: Michael Schippling [mailto:[EMAIL PROTECTED] 
> Sent: Monday, March 17, 2008 9:27 PM
> To: Mark Tsang
> Cc: tinyos-help@millennium.berkeley.edu
> Subject: Re: [Tinyos-help] Utilizing a command from another module,
> 
> I may have spoken out of turn but the 'provides' block in the T1 file is:
> 
>> module NoCRCPacket {
>>   provides {
>>     interface StdControl as Control;
>>     interface BareSendMsg as Send;
>>     interface ReceiveMsg as Receive;
>>     interface SendVarLenPacket;
>>
>>     command result_t txBytes(uint8_t *bytes, uint8_t numBytes);
>>     /* Effects: start sending 'numBytes' bytes from 'bytes'
>>     */
>>   }
>>   uses {
>>     interface ByteComm;
>>     interface StdControl as ByteControl;
>>     interface Leds;
>>   }
>> }
> 
> Which seems to indicate that you could "call txBytes(...)" from your code,
> but I'm resistant to becoming familiar with that special syntax.
> If that doesn't work, then close study of the nesc doc is indicated.
> 
> MS
> 
> 
> Mark Tsang wrote:
>> But NoCRCPacket doesn't have an interface.  It looks to be a standalone
>> module.  Or am I missing something?
>>
>> -----Original Message-----
>> From: Michael Schippling [mailto:[EMAIL PROTECTED] 
>> Sent: Monday, March 17, 2008 5:43 PM
>> To: Mark Tsang
>> Cc: tinyos-help@millennium.berkeley.edu
>> Subject: Re: [Tinyos-help] Utilizing a command from another module,
>>
>> look for documentation on NESC. Basically anything in the interface
>> for a module can be "call"ed from another module.
>> MS
>>
>> Mark Tsang wrote:
>>> I was wondering how I would go about calling a command from another 
>>> module to utilize in my own module.  For instance, I want to use the 
>>> command "txBytes" in NoCRCPacket in my own program MyApp.  What do I 
>>> have to add in my program to do so.  I've read in other threads that I 
>>> need to wire NoCRCPacket to UART and I have done so, but I'm still 
>>> receiving the following error message during compilation:  NOTE:  I'm 
>>> calling txBytes in my Timer.fired command below in the module
>>>
>>>  
>>>
>>> In component `NoCRCPacket':
>>>
>>> /opt/MoteWorks/tos/platform/micaz/NoCRCPacket.nc: In function
>> `receiveTask':
>>> /opt/MoteWorks/tos/platform/micaz/NoCRCPacket.nc:306: Receive.receive 
>>> not connected
>>>
>>>  
>>>
>>>  
>>>
>>> The error message isn't pointing to my program, instead the platform 
>>> file.  What am I doing wrong.  Thanks in advance!
>>>
>>>  
>>>
>>> configuration MyApp {
>>>
>>>   provides {
>>>
>>>                 command result_t txBytes(uint8_t *bytes, uint8_t
>> numBytes);
>>>   }
>>>
>>> }
>>>
>>> implementation {
>>>
>>>   components Main, MyAppM, TimerC, LedsC, NoCRCPacket as NoPacket, UART;
>>>
>>>  
>>>
>>>   Main.StdControl -> TimerC.StdControl;
>>>
>>>   Main.StdControl -> MyAppM.StdControl;
>>>
>>>   Main.StdControl -> NoPacket.Control;
>>>
>>>  
>>>
>>>   MyAppM.Timer -> TimerC.Timer[unique("Timer")];
>>>
>>>   MyAppM.Leds -> LedsC.Leds;
>>>
>>>  
>>>
>>>   txBytes = NoPacket.txBytes;
>>>
>>>  
>>>
>>>   NoPacket.ByteControl -> UART;
>>>
>>>   NoPacket.ByteComm -> UART;
>>>
>>>  
>>>
>>> }
>>>
>>>  
>>>
>>> module MyAppM {
>>>
>>>   provides {
>>>
>>>     interface StdControl;
>>>
>>>                
>>>
>>>   }
>>>
>>>   uses {
>>>
>>>     interface Timer;
>>>
>>>     interface Leds;
>>>
>>>                 interface StdControl as PhotoControl;
>>>
>>>                 interface SendUART;
>>>
>>>                
>>>
>>>                 command result_t txBytes(uint8_t *bytes, uint8_t
>> numBytes);
>>>   }
>>>
>>> }
>>>
>>> implementation {
>>>
>>>  
>>>
>>>   /**
>>>
>>>    * Toggle the red LED in response to the <code>Timer.fired</code>
> event.
>>>    * Start the Light sensor control and sample the data
>>>
>>>    *
>>>
>>>    * @return Always returns <code>SUCCESS</code>
>>>
>>>    **/
>>>
>>>   event result_t Timer.fired()
>>>
>>>   {
>>>
>>>     call Leds.redToggle();   
>>>
>>>                 // send message to UART (serial) port
>>>
>>>                 if (call txBytes((uint8_t *)0x41,(uint8_t *)0x01) != 
>>> SUCCESS)
>>>
>>>                   sending_packet = FALSE;
>>>
>>>                  
>>>
>>>     return SUCCESS;
>>>
>>>   }
>>>
>>>  
>>>
>>>   command result_t StdControl.init() {
>>>
>>>     call Leds.init();
>>>
>>>     }
>>>
>>>  
>>>
>>>   command result_t StdControl.start() {
>>>
>>>     // Start a repeating timer that fires every 1000ms
>>>
>>>     return call Timer.start(TIMER_REPEAT, 1000);
>>>
>>>   }
>>>
>>>  
>>>
>>>   /**
>>>
>>>    * Halt execution of the application.
>>>
>>>    * This just disables the clock component.
>>>
>>>    *
>>>
>>>    * @return Always returns <code>SUCCESS</code>
>>>
>>>    **/
>>>
>>>   command result_t StdControl.stop() {
>>>
>>>     return call Timer.stop();
>>>
>>>   }
>>>
>>>  
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Tinyos-help mailing list
>>> Tinyos-help@millennium.berkeley.edu
>>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

-- 
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew


_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to