GSM data shifting continuously
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: GSM data shifting continuously

  1. #1
    Join Date
    May 2014
    Posts
    3

    GSM data shifting continuously

    Hi,
    I have written a code to get the GSM data on serial port. So when GSM module get's a call it sends the data

    RING+CLIP: "+919823596784",145,"",,"",0".

    However this data keeps on shifting towards right or left. I want to extract the phone number from this data. I thought of detecting first two word i.e RING+CLIP, using Instr function. However even it is present in incoming string, it's giving value 0' it means string is not present in given string. So i can not extract phone number. Moreover data keeps on shifting, so position of those two words is also not fix. Here is the code,

    Code:
    Dim str As String
    Dim val As Integer
    Dim str_1 As String
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
       On Error GoTo errx:
       Dim strValue As String ' define Buffer value from Modem
       MSComm1.CommPort = 6   'comm port no.
       MSComm1.Settings = "9600,n,8,1"
       MSComm1.RThreshold = 47    'no. of chr to receive
       MSComm1.InputLen = 0  '  no. of chr on which oncomm  event fires
        
       MSComm1.PortOpen = True  'open comm port
       MSComm1.Output = "AT + CLIP = 1" + Chr(13)
       Sleep 500
       Exit Sub
       errx:
     MsgBox "error"
    End Sub
    
    Private Sub MSComm1_OnComm()
    'str = " RING+CLIP"
    Select Case MSComm1.CommEvent
    
    ''Events
    Case comEvReceive
    ''Case comEvRing
    str_1 = Text1.Text
    Text2.Text = InStr(str_1, "RING+CLIP")
    ''Text3.Text = Mid(str, 22, 10)
    Case Else
    
    End Select
    
    End Sub
    How to stop shifting of data, and extract desired number from this.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,981

    Re: GSM data shifting continuously

    I'd let in 2 Rings, and then parse. Caller ID comes in after the first ring.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: GSM data shifting continuously

    Quote Originally Posted by djc_247 View Post
    Hi,
    I have written a code to get the GSM data on serial port. So when GSM module get's a call it sends the data

    RING+CLIP: "+919823596784",145,"",,"",0".
    I guess it should be something like
    Code:
    RING
    +CLIP: "+919823596784",145,"",,"",0"
    instead...
    Victor Nijegorodov

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center