View previous topic :: View next topic |
Author |
Message |
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Sun Oct 01, 2017 7:33 pm Post subject: SMS string problem |
|
|
Hi
i have a sim7100 modem wich i have setup to parse the whole incoming message out in one string.
My problem is that the message is divided in two by LF and CR.
Like this:
blabla4324242
hello
Is there a way to read the message without the LF/CR so the message becomes: blabla4324242hello
Many thanx
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Oct 01, 2017 8:08 pm Post subject: Re: SMS string problem |
|
|
Tubeampman wrote: | wich i have setup to parse the whole incoming message out in one string. |
If you've done this, for example by filling a string with incoming single chars, then omitting LF and CR is easy, simple don't add them to the string.
In case the exact two-byte combination LFCR needs to be omitted, set a flag as you detect a LF and shorten the string by one byte at the end, if the CR appears immediately after. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Oct 02, 2017 6:36 pm Post subject: |
|
|
Hi,
would you please send the part of code used to receive the string
I think it is easy to receive all ascii char >31 like that you remove all char as Chr10 Chr13
take care
A true modem use also end and stop Char as STX chr2 and ETX chr3
so to see the code it is a good help to understand what you want.
JP |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Tue Oct 03, 2017 12:03 am Post subject: |
|
|
hi
thanx for helping
I did kinda what MWS said, setting a flag when char 36 ($) arived.
It works now.
I wil post kode after some cleanup.
many thanx |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Mon Nov 13, 2017 9:57 am Post subject: |
|
|
Hi
Sorry for the late thank you post.
A great thanx to MWS and Duval JP for the help.
The following code has been running for a while now without any problems.
'****************************** Read SMS ****************************************************
sub GET_sms
password_counter=10 ' Total caracter count
time_out=0 ' Timeout counter
start timer1
gsm_string = "" ' Empty string
Do
inputbyte = Inkey()
If inputbyte > 0 Then
if inputbyte > 30 then gsm_string = gsm_string + Chr(inputbyte)
if innbyte=36 then dollar_flag=1
if dollar_flag=1 then
password=password+ Chr(innbyte)
decr password_counter
end if
end if
if password_counter=0 then exit do
if time_out > 20 then exit do
reset watchdog
Loop
stop timer1
clear serialin
Bcount = Split(gsm_string , ar(1) , "") ' Splitte stringen med hensyn på mellomrom
For byte_counter = 1 To Bcount
Next
head = left(gsm_string,5)
incoming_number = ar(2)
if head="+CMT:" and password="$5598reset" then relay_flag=1 else relay_flag=0 ' hvis det er en melding som kommer samt rett passord så sett flagg
if head="+CMT:" and password="$5598statu" then status_flag=1 else status_flag=0 ' hvis det er en melding som kommer samt rett passord så sett flagg
chrwait=0
dollar_flag = 0
password=""
head=""
End Sub
'**************************************************************************************************************************************** |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Nov 13, 2017 10:35 am Post subject: |
|
|
takk for svaret ditt, det er alltid hyggelig å motta meldinger som din.
google translation...
JP |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Mon Nov 13, 2017 3:21 pm Post subject: |
|
|
|
|
Back to top |
|
|
|