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 CCS Technical Support

can't read & compare data needed for reading sms functio

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vjn86



Joined: 12 Oct 2009
Posts: 11

View user's profile Send private message

can't read & compare data needed for reading sms functio
PostPosted: Fri Dec 25, 2009 9:17 am     Reply with quote

Hi all, I am trying to write a program that read incoming sms from a GSM modem and sends back a acknowledgment message to the defined number. The acknowledgment message named "hey" should be sent if the mydata[] and mydata1[] are equal and it should send "error" if it isn't equal.

If I define both array:
as equal :
( mydata [] = test ;mydata1[]= test)

or
not equal:
( mydata [] = test ;mydata1[]= testing),

I'm able to get desired output... The problem starts when i try to compare a stream named mydata[] and defined string named mydata1[]= "+CMTI: \"SM\",1/n" as shown in coding. When i use this, I'm not even getting a error message.... What am i possibly wrong at ?

p/s : If I receiving message at location 1, the indication is +CMTI: "SM",1

thanks
Code:

#use delay(clock=20000000)
#fuses hs,nowdt,nolvp,noprotect
#use rs232(baud=9600, bits=8, parity=N, stop=1, xmit=PIN_C6, rcv=PIN_C7, stream=mydata[],)

void main()
{
char mydata[];
  char mydata1[]= "+CMTI: \"SM\",1/n";
  set_tris_c(0x80);
  printf("at\r\n");
  delay_ms(500);
  gets(mydata);

 if(strcmp (mydata,mydata1)==0)
      {
         printf("at+cmgf=1\r\n");
         delay_ms(500);     
         printf("at+csmp=17,168,0,0\r\n");
         delay_ms(500);
         printf("at+cmgs=\"+60136240915\"\r\n");
         delay_ms(3000);
         printf("hey ");
         putc(0x1A);
         delay_ms(10000);
      }
      else
      {
         printf("at+cmgf=1\r\n");
         delay_ms(500);     
         printf("at+csmp=17,168,0,0\r\n");
         delay_ms(500);
         printf("at+cmgs=\"+60136240915\"\r\n");
         delay_ms(3000);
         printf("error ");
         putc(0x1A);
         delay_ms(10000);         
      }
}
vjn86



Joined: 12 Oct 2009
Posts: 11

View user's profile Send private message

PostPosted: Sun Jan 24, 2010 12:32 pm     Reply with quote

erm..can't anyone advice me what to do next ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 24, 2010 12:48 pm     Reply with quote

Quote:
char mydata[];

Where's the size on this ? You have allocated a pointer, but no storage
locations.

Quote:
gets(mydata);

Here you're filling up memory locations, starting at the pointer address,
but the memory locations don't belong to the array. They could belong
to anything else.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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