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

SMS send problems
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 26, 2008 4:31 pm     Reply with quote

You need to post the array declaration statement.
You also need to post the contents of the array, or the code that fills it.
jjacob



Joined: 08 Mar 2008
Posts: 54
Location: PORTUGAL (PORTO)

View user's profile Send private message

PostPosted: Wed Aug 27, 2008 8:51 am     Reply with quote

This is my code for testing sending SMS:

Code:
#include <18F452.h>
#include <stdlib.h>
#include <string.h>
#include <functions_gprs.h>


#define led PIN_A0

void main(){

   char op;
   int i, analog_sensors=0, freq_sensors=0, sr=0;
   long data[32], station=0;
   int32 mobile=0;

analog_sensors=9;
freq_sensors=3;
station=123;
mobile=999988877;

output_high(led);

for(i=0;i<16;i++)
   data[i]=i;
   
output_low(led);

send_SMS(data, analog_sensors, freq_sensors, station, mobile);

output_high(led);


}


The functions_gprs.h :

Code:
// Config header
#include <config.h>

void send_SMS(long *data, int analog_sensors, int freq_sensors, long station, int32 mobile) {

   int i;

   fprintf(sms,"at+cmgf=1\r\n");
   delay_ms(100);
   fprintf(sms,"at+cmgs=%Ld\r\n\n\r", mobile);
   delay_ms(100);

   fprintf(sms,"%04Ld*", station);
   
   for (i=0;i<analog_sensors;i++)
   {
      fprintf(sms,"%04Ld*", data[i]);
      //data[i]=read_sensor(i);
      delay_ms(100);
   }   
   
   for (i=0;i<freq_sensors;i++)
   {
      if(i!=freq_sensors-1) fprintf(sms,"%04Ld*", data[i+12]);
      else fprintf(sms,"%04Ld%c", data[i+12], 0x1A);
      delay_ms(100);
   }   
      //fprintf(sms,"%c", 0x1A);

delay_ms(500);   

}

The config.h :

Code:
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(stream=SMS, baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, stop=1)
//#use rs232(stream=conf, baud=9600, xmit=PIN_??, rcv=PIN_??, parity=N, bits=8, stop=1)

#include <input.c>

#define  MAX_ANALOG_SENSORS       12             // The number of Analog Sensors
#define  MAX_FREQUENCY_SENSORS   4             // The number of Frequency Sensors


Now, after PCM programmer explanation, i think that if i put a while(1) { } after i call the function 'send_SMS' perhaps it would work.
I'm not in my lab, so i can't test this. But am i right ?

Jacob
jjacob



Joined: 08 Mar 2008
Posts: 54
Location: PORTUGAL (PORTO)

View user's profile Send private message

PostPosted: Wed Aug 27, 2008 1:02 pm     Reply with quote

Hi,

what i wanted to say in the last two lines of my last post,
is that if i put a while(1) { } after i call send_SMS(...)
in the main(), perhaps the line 'printf("%c", 0x1A)' would work
and it would be not necessary to put the 'if' in the 'for' loop.

Is this true ? I can not test this for the moment.

Thank you
Jacob
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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