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

READING AN SMS

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



Joined: 11 Jan 2011
Posts: 42

View user's profile Send private message

READING AN SMS
PostPosted: Thu Jan 16, 2020 5:52 am     Reply with quote

Could you please help me,
i saw in a discussion an instruction for reading sms that is : fgets(GSM)
my question is: what is GSM? is that a library or what?
_________________
i am newbe
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 16, 2020 6:08 am     Reply with quote

Quick comment...

GSM = Global System for Mobile...

The code says 'get a string of data from a serial device previously defined as GSM'.

Somewhere before that line a '#USE RS232(...stream=GSM...)' was coded to configure 2 I/O pins to connect to a GSM module.

Check the CCS manual for proper syntax and options !

Be aware that as it's code for 'string' operation , the GSM module MUST return a /0 in order for the PIC to proceed to the next line of code !
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Jan 16, 2020 6:49 am     Reply with quote

No.
Gets, automatically appends a '\0', when a line feed is seen.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 16, 2020 7:21 am     Reply with quote

hmm, I always thought it looked for the 'end of string' delimiter not 'make a string' by adding the /0.
That gets me wondering what happens when there is no linefeed in the incoming data ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Jan 16, 2020 8:03 am     Reply with quote

Gets, terminates when a line feed or null is seen.
It is really best thought of as a 'get line' function.
From K&R:
Quote:

It stops when either the newline character is read or when the end-of-file is reached, whichever comes first.
ILLIAS28



Joined: 11 Jan 2011
Posts: 42

View user's profile Send private message

READING AN SMS
PostPosted: Thu Jan 16, 2020 8:25 am     Reply with quote

Thank you very much for your help guys;
but what is the difference between this command and the AT command for reading SMS: printf("AT+CMGR=%d\r",indx);
_________________
i am newbe
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Jan 16, 2020 8:31 am     Reply with quote

Whoa.
Very different things completely.

Gets, is a C command to 'read' the reply from the modem.
The AT command is a string sent _to_ the modem, to get a reply.

You send an AT command (using printf), and then the reply from the
modem can be read with gets.
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