PDA

View Full Version : Receiving Different String lengths



Jannie
- 23rd January 2009, 19:16
Hi my Friends.

I am trying to receive incoming messages from a GSM modem, using Serin2 command and display it on a 20 x 4 LCD display. First 80 and then last 80

Incoming messages may vary from 1 to 160 characters including a constant qualifier.

All work well if the number of characters is 160.
I break it up as 2 sets of 80 chars (first 80 on LCD pause a few seconds and then last 80).

Serin2 Si,17197,3000,Unlock,[wait ("+27"),str IntNo[1]\9,skip 4,_
str Date[1]\8,skip 1,str Time[1]\8,wait ("$@"),_
str CmdStr[1]\80,str CmdStr2[1]\80]

If it is less than 160, it time out and nothing displays :confused:

Thanks for your help !

Jannie
:)

b1arrk5
- 24th January 2009, 17:25
Hi Jannie,
I can think of two things you might try. First, after you have the \80 in your serin command, add a \13 at the end. This will stop receiving the string variable if there is a carriage return (13) in the incoming message. You may have to find another character to signal the end of your message besides 13, but this might get you started. The other method would require using a hardware uart and keep checking the RCIF flag to see if there is a character waiting to be read. When the buffer is empty you're finished.
Personally, I recommend going with the hardware uart route, and using Darrel Taylor's Instant Interrupts. Then whenever there is data coming into the microprocessor from the modem, your program will go and get it.

Good Luck,
Jerry.

Jannie
- 25th January 2009, 04:53
Thanks Jerry,

I'll give it a try and let you know.
Never used HSERIN before, worth a try.

Thank you for the reply.

Jannie
- 25th January 2009, 12:48
Thanks Jerry,

The carriage return / linefeed did the trick with SERIN2 :)

BR
Jannie

b1arrk5
- 25th January 2009, 16:43
Jannie,
Excellent, I'm glad it worked. I've never used GSM, only CDMA, but I hoped the format for the SMS would be similar.
Hserin can be used with faster speeds, Serin is more limited.

Jerry

Jannie
- 26th January 2009, 05:00
Thanks again Sir :-)

Now 14 years in GSM/UMTS, quite interesting.

BR
Jannie