Hi,

Thanks a lot for your replies. I got the program to work for sending commands 
from mote to hyperterminal. The reason I was sending modem commands was because 
later I want to interface the mote with the modem but was trying to get the 
UART to work first.

I am facing a weird problem now though. When I start my hyperterminal connected 
to the mote, the program only works when I have this external logic analyzer 
(Logic from saleae)  plugged in to the Vcc and ground lines of my 
communication. I need to put the probes of the analyzer on my lines, start its 
simulation, and then all the commands work on my hyperterminal. If I start 
without the analyzer, the communication between mote and PC does not start!!

It very funny. Is there some trigger pin I should be considering? Because 
UartStream does not have any. Here is my new code :

--------------------------------------------------------------------------------

#include "printf.h"

module GSMmodemC @safe()
{
  uses interface Boot;
  uses interface Init as UartInit;
  uses interface StdControl as UartControl;
  uses interface UartStream; 
  uses interface Leds;
  uses interface Timer<TMilli>;
 
}
implementation
{

enum {
    UART_BUF_MAXLEN = 15
};
   
char* uartsendBuf1 = "AT\n\r";
char* uartsendBuf2 = "AT+CMGF=1\n\r";
char* uartsendBuf3 = "AT+CMGS=";
char* uartsendBuf4 = "+6590140252";
char* newline = "\n\r"; 
char* msg = "Hello";
uint8_t recevedByte;
uint8_t stage = 0;
uint8_t flag = 0;
uint8_t uartBuf[UART_BUF_MAXLEN];
/** Count of bytes read into #uartBuf during a reading. */
uint8_t uartBufCount;
  
  event void Boot.booted() {
        
        call UartInit.init();
        call Timer.startPeriodic(3000);
    call UartControl.start();
        //call Timer.startPeriodic(2000);
    
  }  
        
        event void Timer.fired() {
        

        switch (stage) {
                case 0: 
                call UartControl.start();
                call UartStream.send(uartsendBuf1, 4);
                break;
                case 1:
                call UartControl.start();
                call UartStream.send(uartsendBuf2, 11);  //at+cmgf=1
                break;
                case 2:
                call UartControl.start();
                call UartStream.send(uartsendBuf3, 8); // at+cmgs=
                        break;
                case 3:
                call UartControl.start();               
                call UartStream.send(0x22,1);   // "
                break; 
                case 4:
                call UartControl.start();               
                call UartStream.send(uartsendBuf4,11);  //phone number
                break;
                case 5:
                call UartControl.start();               
                call UartStream.send(0x22,1);  // " ""
                break;
                case 6:
                call UartControl.start();               
                call UartStream.send(newline,2); //newline
                break;
                case 7:
                call UartControl.start();               
                call UartStream.send(msg,5);  //message
                break;
                
                case 8:
                call UartControl.start();               
                call UartStream.send(0x1A, 1);   //comtrol z
                break; 
        
        
        }
        
        }
  

  async event void UartStream.sendDone( uint8_t* buf, uint16_t len, error_t 
error )
  {      
        call Leds.led2Toggle();
        stage++;
        if (stage > 8)
        {
        stage = 0;
        }       

        call UartControl.stop();
        
  }
  
  async event void UartStream.receivedByte( uint8_t byte )
  {     
   }

  
  async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t 
error )
  {
  }

}

________________________________________
From: Michael Schippling [[email protected]]
Sent: Tuesday, February 14, 2012 2:29 AM
To: #BHARTI GOEL#
Cc: Eric Decker; [email protected]
Subject: Re: [Tinyos-help] UART sending series of commands to PC

Also I would recommend eliminating the busy-wait delay()
by splitting the whole sending sequence into multiple calls
driven by a timer. It's not much of a delay, but long-running
tasks may end up blocking other tasks which need resources.

MS

Eric Decker wrote:
> It is very strange to be sending modem commands to a pc but okay if you
> must.
>
> You are using UartStream which is split phase.  You need to be catching
> the completion event (signal) from UartStream.sendDone.  When the
> sendDone comes in you can then start up the next string you want to send.
>
> The way you have UartStream.sendDone right now doesn't make a whole lot
> of sense.
>
>
> If you don't know how this works you need to read the basic TinyOS
> documents and tutorials.  Start with Phil's book.
>
> On Mon, Feb 13, 2012 at 12:13 AM, #BHARTI GOEL# <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Hi,
>
>     I am trying to send a series of commands to the PC hyperterminal
>     using UART interface. Now when I send a single command it works
>     fine. But when I send a series of commands it stops working. I have
>     tried to create delays after each command but still it does not
>     work. Can anyone tell me what I can possibly do?
>
>     Here is my code :
>
>     module GSMmodemC @safe()
>     {
>       uses interface Boot;
>       uses interface Init as UartInit;
>       uses interface StdControl as UartControl;
>       uses interface UartStream;
>       uses interface Leds;
>       uses interface Timer<TMilli>;
>
>
>     }
>     implementation
>     {
>
>     // COMMANDS TO BE SENT
>     char* uartsendBuf1 = "AT\n";
>     char* uartsendBuf2 = "AT+CMGF=1\n";
>     char* uartsendBuf3 = "AT+CMGS=";
>     char* uartsendBuf4 = "+6590140252 <tel:%2B6590140252>";
>     char* output = "Hello";
>     char* input;
>     uint16_t inputlen;
>     uint8_t recevedByte;
>
>       event void Boot.booted() {
>
>         call UartInit.init();
>
>         call Timer.startPeriodic(3000);
>         call UartControl.start();
>
>       }
>
>
>     static void delay(uint32_t cycles)
>       {
>         while (--cycles > 0)
>         {
>           //nop();
>         }
>       }
>
>           event void Timer.fired() {
>
>
>         call UartControl.start();
>         call UartStream.send(uartsendBuf1, 3);
>         /*call Leds.led1Toggle();                              // This
>     part does not work
>         delay(5000);
>         call UartControl.start();
>         call UartStream.send(uartsendBuf2, 10);
>         call Leds.led1Toggle();
>         delay(5000);
>         call UartControl.start();
>         call UartStream.send(uartsendBuf3, 8);
>         call Leds.led1Toggle();
>         delay(5000);
>         call UartControl.start();
>         call UartStream.send(uartsendBuf4, 11);
>         call Leds.led1Toggle();
>         delay(5000); */
>       }
>
>
>
>       async event void UartStream.sendDone( uint8_t* buf, uint16_t len,
>     error_t error )
>       {
>
>         call Leds.led0Toggle();
>         call UartStream.enableReceiveInterrupt();
>
>       }
>
>       async event void UartStream.receivedByte( uint8_t byte )
>       {
>
>       if( (char* )byte == "a")
>       {
>       call Leds.led1Toggle();
>       }
>       call Leds.led2Toggle();
>       recevedByte = byte;
>       call UartControl.stop();
>
>       }
>
>       async event void UartStream.receiveDone( uint8_t* buf, uint16_t
>     len, error_t error )
>       {
>
>       }
>
>     }
>
>
>     _______________________________________________
>     Tinyos-help mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
>
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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