wait for a string


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2009
    Posts
    9

    Angry wait for a string

    when i try to read sms 5 then I am waiting for the user no "8801717101959"
    then this code is fine

    Code:
    SerOut2 txd,Baud,["at+cmgr=5",13]
    SerIn2 rxd,Baud,500,delet_sms,[wait ("+8801717101959")]
    But I am trying to wait for a string " str phoneno\14 "
    Because the authorized phone no is in phoneno[14]

    Please help me

  2. #2
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Waiting for a string within SERIN2

    Hello,
    While I am not an expert, I am confused by the line in your code that reads:
    SerIn2 rxd,Baud,500,delet_sms,[wait ("+8801717101959")]
    That command will wait for that string for 500 milliseconds, and if it is not received, it will jump to the label delet_sms.

    What seems to be missing is the variable into which you want to stuff subsequent serial input that will follow "+8801717101959". Is that variable named phoneno?

    Remember that the string you wait for is not the data part of the input, it is just a trigger to accept what follows and place it into a variable. If I have understood your intentions correctly, you want to gather some additional set of numbers and place them into a variable after receiving that quoted string "+8801717101959". If so, your syntax could be:
    SERIN2 rxd,Baud,500,delet_sms,[wait ("+8801717101959"), phoneno]

    Is this what you had intended?

    Bob

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,809


    Did you find this post helpful? Yes | No

    Default

    And why especially message 5? Are yousure about this?

    What if you have deleted already one and now you have 4 SMS?

    Ioannis

  4. #4
    Join Date
    Mar 2009
    Posts
    9


    Did you find this post helpful? Yes | No

    Angry

    Code:
    SerOut2 txd,Baud,["at+cmgr=5",13]
    SerIn2 rxd,Baud,500,delet_sms,[wait ("+8801717101959")]

    I just read sms memory index 5, and check the sender no by waiting the phone no [wait ("+8801717101959")]. Its a authorized phone no. If the sender phone no don't match then I delete it. If match then i know what to do.(Tested)

    I always read and delete index 5. So any new sms first arrive in index 5.


    My problem is, the authorized phone no saved in EEprom. And its may change time to time. So I need to wait for a string type array.

    I have tried with that . But compiler show error this line
    Code:
    SerIn2 rxd,Baud,500,delet_sms,[wait("#str phoneno\14"),skip 32,str inbox\8]

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    This snippet should solve your problem.
    Code:
    EEprom 0,[49,55,49,55,49,48,57,53,57]  '  your number without the area code 1717101959
    
    InBox    var Byte  [8] ' make your array larger so you can use a byte as command
    Num0    var Byte  [9]
    Num1    var Byte  [9]
    Flag      var byte
    Try        var Byte
    A0        var Byte
    
    For A0=0 to 9
    Read A0,Num0[A0] ' here you load you number in array Num0
    Next A0
    
    
    IniCall:
    Try=Try+1
    If Try>5 then delet_sms ' if counter >5 then abort ( if 5 cycles are too many reduce them to an acceptable number)
    SerOut2 txd,Baud,["at+cmgr=5",13]
    SerIn2 rxd,Baud,1000,IniCall,[wait ("+880"),Str Num1\9,skip 32,str inbox\8] ' here you load the incoming number into array Num1
    
    Try=0
    Flag=1
    For A0=0 to 9
    If Num0[A0]<>Num1[A0] then Flag=0 ' here you compare the two array if not all digits agree then Flag is set to zero
    next A0
    
    If flag=0 then delet_sms ' flag reports "not corrected number" so delete sms
    
    
    'your code here to work with the array  inbox
    
    goto mainLoop ' your code mainLoop
    
    delet_sms:
    Try=0
    
    ' your code for deleting sms
    
    
    'If you make an  inbox array equal to 11 elements then you can use it to change the number when needed
    For instance if inbox[10]= 100 then gosub Change 
    
    
    Change:
    
    For A0 =0 to 9
    Write A0, inbox[A0]
    Num0[A0]=inbox[A0]
    Next A0
    Return

    Your number is stored into the eeprom and is loaded in the array Num0 at runtime. I am not sure if "880" is the area code.

    If Try>5 then there is not sms, so you don't need to delete it. Trying to delete is dangerous because you could delete an incoming sms.

    Al.
    Last edited by aratti; - 1st April 2009 at 22:59.
    All progress began with an idea

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,809


    Did you find this post helpful? Yes | No

    Default

    My question still is what if you have deleted all SMS and the new valid arrives at location 1?

    Ioannis

  7. #7
    Join Date
    Mar 2009
    Posts
    9


    Did you find this post helpful? Yes | No

    Wink

    sms index 1,2,3,4 are used to store the emergency sms. These sms are used to notify the user .

  8. #8
    Join Date
    Mar 2009
    Posts
    9


    Did you find this post helpful? Yes | No

    Thumbs up thanks aratti

    Hi aratti . Thanks for your help. I have solved it.
    Can you please inform me one more thing, When any new sms arrived, the GSM modem send a notification " +CMTI: "SM",5 " .

    How i can use this notification to interrupt in my program.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,809


    Did you find this post helpful? Yes | No

    Default

    Your program might be interrupted only by an Hardware Interrupt, say from the USART module.

    So, if you want a fast interrupt system, have a look at Darrels Instant Interrupt.

    Then every time you have an RS-232 activity, the ISR will take care of the event. Store the incoming data in an array and do a compare byte-to-byte with a stored reference array, say in the EEPROM.

    I am working on a similar project and may post a snipet as soon as I get it working.

    Ioannis

  10. #10
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Your program might be interrupted only by an Hardware Interrupt, say from the USART module.

    So, if you want a fast interrupt system, have a look at Darrels Instant Interrupt.

    Then every time you have an RS-232 activity, the ISR will take care of the event. Store the incoming data in an array and do a compare byte-to-byte with a stored reference array, say in the EEPROM.

    I am working on a similar project and may post a snipet as soon as I get it working.

    Ioannis
    that would be nice

    --
    http://www.mtskola.com

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Can you please inform me one more thing, When any new sms arrived, the GSM modem send a notification " +CMTI: "SM",5 " .

    How i can use this notification to interrupt in my program.
    The best way is the one that Ioannis suggested you in post #9.

    For "HSERIN" instruction you have to use specific pins of your pic micro (you didn't say the type), which are the USART module, plus the DT interrupt routine.

    Serch the forum for DT interrupt to learn more or go to this link: http://www.picbasic.co.uk/forum/showthread.php?t=3251


    XXXXX you can download the project for sms controller at this link:http://techni.caliti.es/blog/2008/12...ontroller.html

    since the project is well documented, you could see the technique used to activate 8 relays or read the status of 8 inputs all via sms command.


    Al.
    Last edited by aratti; - 2nd April 2009 at 23:21.
    All progress began with an idea

  12. #12
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    The best way is the one that Ioannis suggested you in post #9.

    For "HSERIN" instruction you have to use specific pins of your pic micro (you didn't say the type), which are the USART module, plus the DT interrupt routine.

    Serch the forum for DT interrupt to learn more or go to this link: http://www.picbasic.co.uk/forum/showthread.php?t=3251


    XXXXX you can download the project for sms controller at this link:http://techni.caliti.es/blog/2008/12...ontroller.html

    since the project is well documented, you could see the technique used to activate 8 relays or read the status of 8 inputs all via sms command.


    Al.
    yes but i want to make my own ....."why make things simple if you could complicate them"

Similar Threads

  1. How about String Variables?
    By mytekcontrols in forum PBP Wish List
    Replies: 40
    Last Post: - 20th January 2015, 12:53
  2. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  5. USB Interface using PIC
    By Tissy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd May 2006, 16:04

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts