CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Receiving TXT messages - SUPERSEDED / OLD
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Jan 30, 2013 7:59 am     Reply with quote

it means that you are not finding the "+CMTI" string.

make sure your module is set to send the +CMTI string... i think it is called an "Unsolicited message"

Code:
         output_low(PIN_D1);           // off receive ready light.
         counter_search=2;

         HitCounter=0;

         while((HitCounter!=5)&&(counter_search<8))
         {
            if(Recieve_String[counter_search]==StrCMTI[counter_search-2])
            HitCounter++;

            counter_search++;
         }


the code above starts comparing character by character... if it gets 5 characters in a row to be the same, then the string is "found"

notice that i start comparing Recieve string from position #2:

Code:
         counter_search=2;


This is because the module will respond:

"\n \r + C M T I \n \r" < ----- Module response
0 1 2 3 4 5 6 7 8 < ----- index position


Make sure your module responds as described... the number of characters replied by the module is important and the CASE of the response is important...

you should try to run the the entire sequence of the program _manually_ in hyperterminal so that you know what responses you are and are not getting from the module...

basically pretend you are the pic and send what ever the code is suposed to send and check what the module replys agains what the code expects...

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
ArthurWong



Joined: 28 Jan 2013
Posts: 11

View user's profile Send private message MSN Messenger

PostPosted: Thu Jan 31, 2013 10:06 am     Reply with quote

Gabriel wrote:
it means that you are not finding the "+CMTI" string.

make sure your module is set to send the +CMTI string... i think it is called an "Unsolicited message"

Code:
         output_low(PIN_D1);           // off receive ready light.
         counter_search=2;

         HitCounter=0;

         while((HitCounter!=5)&&(counter_search<8))
         {
            if(Recieve_String[counter_search]==StrCMTI[counter_search-2])
            HitCounter++;

            counter_search++;
         }


the code above starts comparing character by character... if it gets 5 characters in a row to be the same, then the string is "found"

notice that i start comparing Recieve string from position #2:

Code:
         counter_search=2;


This is because the module will respond:

"\n \r + C M T I \n \r" < ----- Module response
0 1 2 3 4 5 6 7 8 < ----- index position


Make sure your module responds as described... the number of characters replied by the module is important and the CASE of the response is important...

you should try to run the the entire sequence of the program _manually_ in hyperterminal so that you know what responses you are and are not getting from the module...

basically pretend you are the pic and send what ever the code is suposed to send and check what the module replys agains what the code expects...

G.


Hi Gabriel, i can get the "+CMTI" at the hyper terminal and my PIC also can trigger when receive the message but it is until the coding step below

I just can work until output_low(PIN_D1)(int SMSALERT()), but the problem is when i send "!LED4 1", the command look like can't read it and the output part "output_high(PIN_B4)(Void DO_CMD())" can't trigger after receive my message...

Just "output_low(PIN_D1)" then go back to starting again(int TEST_AT() )...

then Gabriel i would like to ask what is the line of this coding use for
"counter_read=0; "?

is that to trigger others when interrupt was trigger? because it look like just can work until "output_low(PIN_D1)(int SMSALERT())" and cant trigger
"output_high(PIN_B4)(Void DO_CMD())"

need some advice from u Gabriel...TQ

Code:
int SMSALERT()
{
   const char StrCMTI[]={"+CMTI"};

         counter_read=0;

         While(counter_read<=16)      // read all data
         {
            output_high(PIN_D1);          // signal ready to receive sms
         }
         counter_read=0;

         Delay_ms(500);              // ignore all remaining characters recieved..if any.
         output_low(PIN_D1);           // off receive ready light.
         counter_search=2;

         HitCounter=0;

         while((HitCounter!=5)&&(counter_search<8))
         {
            if(Recieve_String[counter_search]==StrCMTI[counter_search-2])
            HitCounter++;

            counter_search++;
         }
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Jan 31, 2013 12:32 pm     Reply with quote

you need to understand how the code looks for the Strings.

you also need to understand that if the code fails to find the +CMNI string, it will loop back to the begining... and wont even read the sms...

look at the structure of calls:

Code:
while(1)
{

 if(TEST_AT())
 {
    if(SET_MEM())
    {
      if(SET_PDU())
      {
        if(SET_CNMI())
        {
          if(SMSALERT())
          {
            if(READ_SMS())
            {
               if(GET_CMD())
               {
                  if(DEL_SMS())
                  {
                     DO_CMD();
                  }
               }
               else
               DEL_SMS();
            }
          }
        }
      }
    }
  }

}


if one IF fails the code wont execute any more code and loop back to the beggining.

Pin D1 goes on when the serial buffer has one or more characters in it... and it goes low after its got 16 chars and a 500ms period expires.

it THEN looks for the +CNMI string... which its not finding and thus getting back to The AT test...



MORE INPORTANTLY... TEST THIS FIRST:

"!LED4 1" is NOT the right command...

These ARE the right commands:
Code:
const char CMD1[8][7]={"Led1 0","Led1 1","Led2 0","Led2 1","Led3 0","Led3 1","Led4 0","Led4 1"};


this is CASE SENSITIVE....




furthermore:

Quote:
then Gabriel i would like to ask what is the line of this coding use for
"counter_read=0; "?


"counter_read" is the index for the Main Serial Buffer...



G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
ArthurWong



Joined: 28 Jan 2013
Posts: 11

View user's profile Send private message MSN Messenger

PostPosted: Fri Feb 01, 2013 9:23 pm     Reply with quote

The command i should send is start with "!" first right Gabriel? Since it need to detect "!" first then only continue with the command....so based on the coding i should put "!Led4 1" right?
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 7:03 am     Reply with quote

yes!
_________________
CCS PCM 5.078 & CCS PCH 5.093
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Feb 02, 2013 4:55 pm     Reply with quote

In that main "while()" there are enough Delay_ms(500); 's
and longer yet, to take a long nap per execution pass.

I'm also a bit leery about the situation that obtains with as few as one mangled character in the nested I/O block.

Fault tolerance is NOT a shining aspect of this implementation.
I would consider a prioritized method of doing this that perhaps has an
alternate set of conditionals.

Just my 2 cents worth.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Feb 04, 2013 9:31 am     Reply with quote

asmboy, I totally agree with you...

Like it say on the OP, this is not a perfect or efficient code...

it was my first attempt at GSM/SMS.

It was only my intention to offer a "working" starting point for others.


it does work... but it could be WAY better.

I am working on a cleaner, completely new "driver"...

it should reflect some of the things ive learned along the way... should be ready soon..

I haven't been coding much lately since i was training for IronMan 70.3 here in Panama... which was yesterday, and i successfully finished in 6:30 hours...

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
ArthurWong



Joined: 28 Jan 2013
Posts: 11

View user's profile Send private message MSN Messenger

I CAN DO IT
PostPosted: Wed Feb 06, 2013 10:56 am     Reply with quote

Hi Gabriel,after a few days try, finally i successful make the coding to be function...now i am on the way modify it....THANK YOU very much Gabriel...u really help me a lot with this project
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Feb 06, 2013 3:23 pm     Reply with quote

Awesome news!
Congratulations.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
rennelmallari



Joined: 02 Feb 2013
Posts: 8

View user's profile Send private message

PostPosted: Mon Feb 25, 2013 2:12 am     Reply with quote

Hey Gabriel.

When will we able to see your update on this code?
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Feb 25, 2013 8:19 am     Reply with quote

... give me about a week...

i just got a huge job and ive been busy as hell working on the hardware...

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
rennelmallari



Joined: 02 Feb 2013
Posts: 8

View user's profile Send private message

PostPosted: Mon Feb 25, 2013 8:52 am     Reply with quote

That would be great.. so excited to see that, it would be helpful because i have project defense.. ^_^
rennelmallari



Joined: 02 Feb 2013
Posts: 8

View user's profile Send private message

PostPosted: Sun Mar 10, 2013 6:35 pm     Reply with quote

Hi Gab, i tried your code but i'm stuck here.

Code:

int TEST_AT()
{
         counter_read=0;

         printf("AT");                //send command
         putchar(0x0D);                //send return ('enter' in hyperterminal)

         output_high(PIN_B1);  <--stucked :(
         While(counter_read<=8)             //"A T \R \R \N O K \R \N" characters returned by modem
         {
         }
         output_low(PIN_B1);

         counter_read=0;
         Delay_ms(500);               // ignore all remaining characters received

         if(GET_OK(0X0A))
            Return(1);
         else return(0);

}


My hyperterminal reply just "OK" when i enter "AT".
I use GSM SIM900D. Hope you can help me. Thanks.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Mar 11, 2013 7:19 am     Reply with quote

Hi,

First off i appologize for not updating the code as i said i would...
I'm working on a large proyect right now since 3 weeks and its taken all of my time....

.... to your question:

from what i understand you are stuck in the loop:

Code:
         output_high(PIN_B1);  <--stucked :(
         While(counter_read<=8)             //"A T \R \R \N O K \R \N" characters returned by modem
         {
         }


see the Comment next to the loop...
it is expecting to receive ATLEAST 8 characters.

from what you posted:
Quote:
My hyperterminal reply just "OK" when i enter "AT".


I assume you dont have local echo on....
so your modem is only replying "OK\r\n" and thus not completing the 8+ characters required to exit the loop...


Code:
int TEST_AT()
{
         counter_read=0;

         printf("AT");                //send command
         putchar(0x0D);                //send return ('enter' in hyperterminal)

         output_high(PIN_B1); 
         While(counter_read==0)    // CHANGED THIS
         {
         }
         output_low(PIN_B1);

         counter_read=0;
         Delay_ms(1000);               // CHANGED THIS

         if(GET_OK(0X0A))
            return(1);
         else return(0);

}



Try the function above... i modified it a bit...
try to understand what i did and you could modify the other functions the same way...


G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed May 01, 2013 9:29 pm     Reply with quote

++++++++++++++++++++++++++++++++++++++++++++++
EDIT:
Please refer from now on to this code:
http://www.ccsinfo.com/forum/viewtopic.php?t=50390
I WILL NOT BE SUPPORTING THIS CODE ANY MORE
++++++++++++++++++++++++++++++++++++++++++++++


FINALLY...

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group