Go to last post By: J. Mark Wolf
Today 01:01
Forum: Proton Plus Compiler v3
Starter: SELCUK
Views: 0
Replies: 1
Yesterday 23:36
Forum: Proton 24
Starter: charliecoultas
Views: 0
Replies: 7
Yesterday 21:34
Forum: Proton Plus Compiler v3
Starter: H-bert
Views: 2350
Replies: 51
Yesterday 11:49
Forum: The Lounge
Starter: yvesmazzon
Views: 0
Replies: 11
+ Reply to Thread
Results 1 to 9 of 9

Thread: GSM communication with SIM900406 days old

  1. #1
    Inactive member tincho74's Avatar
    Join Date
    Oct 2014
    Posts
    1
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    77.77 MB

    2 Not allowed!

    Default GSM communication with SIM900

    Hello how are you?
    I have a little problem, I am communicating with a PIC 16F877A SIM900 module and it turns out that when the pic sends me a text message to my cell phone, this message is repeated over and over again, as I cut sending messages?
    Thank you.

  2. #2
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,900
    Thumbs Up
    Received: 28
    Given: 35
    Total Downloaded
    1.20 GB

    1 Not allowed!

    Default Re: GSM communication with SIM900

    Hi Tincho- and welcome to the forum!
    If you can post a snippet of your code I'll try to help. By the way, I'm just starting on a project using a SIM800. Glad to know other PDS users are working with GSM communications.

    -Rick

  3. #3
    Junior Member RSteve's Avatar
    Join Date
    Aug 2008
    Posts
    9
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    183.06 MB

    0 Not allowed!

    Default Re: GSM communication with SIM900

    Hi Rick!
    I know it's been a while, but I would have a couple of questions about communication with a SIM800L modem ...
    First of all, if it happens to you that the modem sometimes (really often... ) sends garbage to comport ?
    Second, how do you manage the UART interrupts with long strings (ex. when an SMS arrives...)? I work with a 16F1827 PIC.

    Thanks, Steve

  4. #4
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,188
    Thumbs Up
    Received: 217
    Given: 78
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: GSM communication with SIM900

    I've communicated with modems for many years now, and the receiver code needs to be robust. I would also recommend an 18F device because they have better control over RAM.

    A snippet of a typical receiver routine is shown below. There is no need for a USART interrupt:

    Code:
        Device = 18F452
        Declare Xtal = 40
    
        Dim tResponseTimeOut As Bit
        Dim tResponseOverflow As Bit
        
        Dim wHrsinTimeoutValue As Word
        Dim wCharpos As Word
        Dim bChar As Byte
        
        Symbol SizeOfReceiveBuffer = 1000
        Dim bModemReceiveBuffer[SizeOfReceiveBuffer] As Byte
        
        Dim wFSR1 As FSR1L.Word
        
        GoTo Main
        
    '-----------------------------------------------------------------------------------------------------------------------
    ' Get the response from the modem (with an alterable timeout value)
    ' Input    : wHrsinTimeoutValue holds the timeout value (in ms)
    ' Output   : Byte array bModemReceiveBuffer
    '          : Bit tResponseTimeOut will be true if a timeout occured
    '          : Bit tResponseOverflow will be true if the response overflowed the string variable holding it
    ' Notes    : Discards any initial <CR> or <LF> bytes transmitted by the modem
    '
    $define Modem_WaitForResponse(pTimeout) '
        wHrsinTimeoutValue = pTimeout       '
        GoSub _ReceiveResponse
    
    _ReceiveResponse:
        wFSR1 = AddressOf(bModemReceiveBuffer)                      ' Point FSR1L\H to the beginning of the receive buffer
        wCharpos = 0
    ReceiveContinue:
        HSerIn wHrsinTimeoutValue,RecResponseTimeout,[bChar]        ' Receive a byte from the modem
        If bChar <= 13 Then GoTo ReceiveContinue                    ' Look again if it's a <CR> or less
        POSTINC1 = bChar                                            ' Add the character received to the array
    
        Repeat                                                      ' Create a loop 
            HSerIn wHrsinTimeoutValue,RecResponseTimeout,[bChar]    ' Receive a byte from the modem (with timeout) 
            If bChar = 13 Then                                      ' Is the byte a <CR> (13)? 
                INDF1 = 0                                           ' Yes. So add a null to terminate the array 
                tResponseOverflow = 0                               ' Indicate not overflowed 
                tResponseTimeOut = 0                                ' Indicate not timed out 
                GoTo RecResponseExit                                ' Exit the subroutine 
            EndIf
            POSTINC1 = bChar                                        ' Otherwise. Add the character received to the array 
            Inc wCharpos                                            ' Move up to the next position within the string
        Until wCharpos >= SizeOfReceiveBuffer                       ' Until the end of the array's length is reached
        tResponseOverflow = 1                                       ' Indicate that the string overflowed
    RecResponseTimeout:                                             ' Come here if a serial timeout occured
        tResponseTimeOut = 1                                        ' Indicate a timeout occured
    RecResponseExit:
        Return
        
    '-----------------------------------------------------------------------------------------------------------------------
    Main:
        Modem_WaitForResponse(1000)
        HRSOutLn Str bModemReceiveBuffer
        Stop
    With the above code, any characters athat are not wanted. i.e. non ASCII types can be discarded and not added to the final array. The one thing not to do with a modem is simply receive bytes from it, because they are notorious for giving out crap so for reason. Control needs to be had within the receiving code so that any crap can be ignored, or even broken out of if too much crap is present, and set a bit to say so etc...
    Last edited by Les; 17th July 2017 at 10:07.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  5. #5
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,188
    Thumbs Up
    Received: 217
    Given: 78
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: GSM communication with SIM900

    And here's an adaptation of the above routine that waits for the "OK" text from the modem.

    See what I mean about creating your own receive routine? It can be adapted for any occurance:

    Code:
        Device = 18F452
        Declare Xtal = 40
    
        Dim tReceivedOK As Bit
        Dim tResponseTimeOut As Bit
        Dim tResponseOverflow As Bit
        
        Dim wHrsinTimeoutValue As Word                                          ' The timeout (in Milliseconds)
        Dim wCharpos As Word                                                    ' Position within the byte array receive buffer
        Dim bChar As Byte                                                       ' The character received from the modem
        
        Dim bModemReceiveBuffer[1000] As Byte                                   ' The receive buffer
        
        Dim wFSR1 As FSR1L.Word
        
        GoTo Main
        
    '-----------------------------------------------------------------------------------------------------------------------
    ' Get the response from the modem (with an alterable timeout value) and keep receiving until "OK" found
    ' Input     : wHrsinTimeoutValue holds the timeout value (in ms)
    ' Output    : Byte array bModemReceiveBuffer
    '           : Bit tReceivedOK will hold 1 if the "OK" text was received
    '           : Bit tResponseTimeOut will be 1 if a timeout occured
    '           : Bit tResponseOverflow will be 1 if the response overflowed the string variable holding it
    ' Notes     : Discards any initial <CR> or <LF> bytes transmitted by the modem
    '           : Uses a very large byte array for storage
    '
    $define Modem_WaitForOK_Response(pTimeout) '
        wHrsinTimeoutValue = pTimeout          '
        GoSub _Modem_WaitForOK_Response
    
    _Modem_WaitForOK_Response:
        tReceivedOK = 0                                                         ' Default to an "OK" text not being received
        wFSR1 = AddressOf(bModemReceiveBuffer)                                  ' Point FSR1L\H to the beginning of the receive buffer
        wCharpos = 0
    _Modem_ReceiveOK_Continue:
        HSerIn wHrsinTimeoutValue,_Modem_RecOK_Timeout,[bChar]                  ' Receive a byte from the modem
        If bChar <= 13 Then GoTo _Modem_ReceiveOK_Continue                      ' Look again if it's a <CR> or less
        POSTINC1 = bChar                                                        ' Add the character received to the array
        If bChar = "O" Then                                                     ' Is the first byte "O"?
            Repeat                                                              ' Yes. So form a loop
                HSerIn wHrsinTimeoutValue,_Modem_RecOK_Timeout,[bChar]          ' Receive another byte from the modem (with timeout)
                If bChar = "K" Then                                             ' Is the byte a "K"?
                    POSTINC1 = bChar                                            ' Yes. So add the character received to the array
                    INDF1 = 0                                                   ' Add a null to terminate the array
                    tResponseOverflow = 0                                       ' Indicate not overflowed
                    tResponseTimeOut = 0                                        ' Indicate not timed out
                    tReceivedOK = 1                                             ' Indicate that we received the OK text
                    GoTo _Modem_RecOK_Exit                                      ' Exit the subroutine
                Else                                                            ' Otherwise...
                    If bChar <> 10 Then POSTINC1 = bChar                        ' Add the character received to the array
                EndIf
                Inc wCharpos                                                    ' Move up to the next position within the string
            Until wCharpos >= SizeOf(bModemReceiveBuffer)                       ' Until the end of the array's length is reached
        Else                                                                    ' Otherwise...
            Repeat                                                              ' Form a loop
                HSerIn wHrsinTimeoutValue,_Modem_RecOK_Timeout,[bChar]          ' Receive a byte from the modem (with timeout)
                If bChar = "O" Then                                             ' Is the byte an "O"?
                    POSTINC1 = bChar                                            ' Yes. So add it to the array, just in case the next byte is not "K"
                    HSerIn wHrsinTimeoutValue,_Modem_RecOK_Timeout,[bChar]      ' Receive another byte from the modem (with timeout)
                    If bChar = "K" Then                                         ' Is the byte a "K"?
                        POSTINC1 = bChar                                        ' Yes. So add it to the array
                        INDF1 = 0                                               ' Add a null to terminate the array
                        tResponseOverflow = 0                                   ' Indicate not overflowed
                        tResponseTimeOut = 0                                    ' Indicate not timed out
                        tReceivedOK = 1                                         ' Indicate that we received the OK text
                        GoTo _Modem_RecOK_Exit                                  ' Exit the subroutine
                    Else                                                        ' Otherwise...
                        If bChar <> 10 Then                                     ' Is the byte a line feed (10)?
                            POSTINC1 = bChar                                    ' No So add the character received to the array
                            Inc wCharpos                                        ' Move up to the next position within the string
                        EndIf
                    EndIf
                Else                                                            ' Otherwise...
                    If bChar <> 10 Then                                         ' Is the byte a line feed (10)?
                        POSTINC1 = bChar                                        ' No So add the character received to the array
                        Inc wCharpos                                            ' Move up to the next position within the string
                    EndIf
                EndIf
            Until wCharpos >= SizeOf(bModemReceiveBuffer)                       ' Until the end of the array's length is reached
        EndIf
        tResponseOverflow = 1                                                   ' Indicate that the string overflowed
    _Modem_RecOK_Timeout:                                                       ' Come here if a serial timeout occured
        tResponseTimeOut = 1                                                    ' Indicate a timeout occured
    _Modem_RecOK_Exit:
        Return
        
    '-----------------------------------------------------------------------------------------------------------------------
    Main:
        Modem_WaitForOK_Response(1000)
        HRSOutLn Str bModemReceiveBuffer
        Stop
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  6. #6
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,900
    Thumbs Up
    Received: 28
    Given: 35
    Total Downloaded
    1.20 GB

    1 Not allowed!

    Default Re: GSM communication with SIM900

    Hi Steve-
    I don't want you to think I'm ignoring you. Les's comments are light years ahead of anything I've done with the SIM900 (Actually I'm using the SIM800 now).

    In my application most of the text I am receiving from the modem is responses to commands, never SMS.

    -Rick

  7. #7
    Junior Member RSteve's Avatar
    Join Date
    Aug 2008
    Posts
    9
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    183.06 MB

    0 Not allowed!

    Default Re: GSM communication with SIM900

    I now Les's codes are "dream-code"...Rick.Thank You!
    About my questions,
    I know that in a 18F would be easier to implement the communication routine but, the enhanced mid-range PIC and the HW-UART interrupt routine is a requirement for this project...( I have a Amicus board and the Buffered_Hserin.bas example from samples directory would be great for start, but... )
    So far i managed to make this code, which works but i don't like the byte array to string conversion part.
    Examples of received strings:
    +CMGR: "REC UNREAD","XXXXXXXXXXXX","","17/07/18,08:30:04+12"
    *7777
    or
    +CPBR: 1,"XXXXXXXXXXXX",145,""
    or
    +CLIP: "XXXXXXXXXX",129,,,,0
    or
    +CMTI: "SM",1

    The received string always begins and ends with "CRLF".

    What i need is to extract the "instruction" that's "CMGR" or "CLIP" or "CMTI"...and the number "XXXXXXXXXXX"
    Here is the code:

    Code:
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 16F1827
    Declare Xtal = 32
    Declare Reminders Off
    @ CONFIG_REQ = 0 ; Override Compiler's configuration settings
    Asm-
    __Config _Config1, 0x2E0C ;FOSC_INTOSC & WDTE_ON & PWRTE_ON & MCLRE_OFF & CP_ON & CPD_ON & BOREN_ON & CLKOUTEN_OFF & IESO_OFF & FCMEN_ON 
    __Config _Config2, 0x1FFF ;WRT_OFF & PLLEN_ON & STVREN_ON & BORV_LO & LVP_OFF 
    Endasm-
    Declare Reminders On
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    
        Declare Dead_Code_Remove = On                   ' Some extra Optimisation
        Declare Optimiser_Level = 1
        On_Hardware_Interrupt int 
        TRISA=%00000000
        LATA.1 = 0
        PORTA = 0
        TRISB=%10011011  
        OSCCON = %11110000                           ' INTOSC 8 x 4 = 32 Mhz
        INTCON = 0
        PIE1 = 0
        PIE2 = 0
        PIE3 = 0
        PIE4 = 0
        APFCON0 = 0
        APFCON1 = 0
        CLKRCON = 0                                  ' Reference Clock module is disabled
        ANSELA = 0                                   ' PORTA digital
        ANSELB = 0                                   ' PORTB digital
        FVRCON = 0
        ADCON0 = 0
        DACCON0 = 0
        SRCON0 = 0
        CM1CON0 = 0                                  ' Comparator control register 0 ( Comparator is disabled )
        CM2CON0 = 0                                  ' Comparator control register 1 ( Comparator is disabled )
        CM1CON1 = 0                                  ' Comparator control register 0 ( Comparator is disabled )
        CM2CON1 = 0                                  ' Comparator control register 1 ( Comparator is disabled )
        MDCON = 0                                    ' Modulation control register off
        CPSCON0 = 0
        WDTCON = %00011101                           ' Set wdt for 16 secs.
    
    'Calculated Baudrate = 19185 @ Xtal 32MHz, Error = -0.08%
    Declare Hserial_RCSTA  = 144                     ' Enable continuous receive
    Declare Hserial_TXSTA  = 36                      ' Enable transmit, BRGH = 1
    Declare Hserial_Clear  = On                      ' Clear overflow automatically
    Declare Hserial_SPBRG  = 160                     ' Baud Rate Generator Low Byte Value
    SPBRGH                 = 1                       ' Baud Rate Generator High Byte Value
    BAUDCON.3              = 1                       ' Enable the 16 bit Baud Rate Generator
    
    
    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Create some variables~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
        Symbol RCIF  PIR1.5                          ' RX int flag
        Symbol RCIE  PIE1.5                          ' RS232 IE
        Symbol CREN  RCSTA.4                         ' Continuous Receive Enable bit
        Symbol FERR  RCSTA.2                         ' Framing error flag
        Symbol OERR  RCSTA.1                         ' Overrun error flag
        Symbol PEIE  INTCON.6                        ' peripheral int enable
        Symbol GIE   INTCON.7                        ' Global Ints
        Symbol OKAY PORTA.0
        Symbol Stat PORTA.2
        
        
        Dim i As Byte
        Dim d As Byte
        Dim a As Byte
        Dim dummy[28] As Byte
        Dim instr As String * 4
        Dim temp1 As String * 15
        Dim num As String * 15
        Dim dummy_str As String * 28
        
        While GIE = 1: GIE = 0: Wend
        
        GoTo Main
    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Interrupt rtn~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    int:      
    Context Save                               
            If RCIF = 1 Then                                   ' interrupt has happened...... source: USART RX
                If OERR = 1 Or FERR = 1 Then                   ' If overrun error
                    CREN = 0                                   ' Reset port
                    CREN = 1
                    GoTo ex_int 
                EndIf   
                 Inc d
                 dummy[d] = RCREG
                 If dummy[d-1] = $0D And dummy[d] = $0A Then
                     dummy_str = dummy[0]+dummy[1]+dummy[2]+dummy[3]+dummy[4]+dummy[5]+dummy[6]+dummy[7]+dummy[8]+dummy[9]+dummy[10]+dummy[11]+_
                     dummy[12]+dummy[13]+dummy[14]+dummy[15]+dummy[16]+dummy[17]+dummy[18]+dummy[19]+dummy[20]+dummy[21]+dummy[22]+dummy[23]+_
                     dummy[24]+dummy[25]+dummy[26]+dummy[27]             
                     instr = Mid$(dummy_str,3,4)
                     temp1 = Mid$(dummy_str,10,20)             ' get the number string
                     Clear num
                     For a = 0 To 20
                     If temp1[a] > $2A And temp1[a] < $3A Then num = num + temp1[a]   ' filter out the numbers from the string
                     If temp1[a] = $22 Or temp1[a] = $2C Then Break
                     Next
                     Clear dummy
                     Clear temp1         
                     d = 0
                 EndIf
            EndIf
    ex_int:
            RCIF = 0
            Low Stat
    Context Restore                                        ' Restore regs and carry on   
    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Main program loop starts here~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Main:
            OKAY = 1                                       ' Low RESET PIN on SIM800L board
            For i = 0 To 20                                '
            Toggle Stat                                    ' Delay 1200 ms, feedback - blink led 
            DelayMS 120
            Next                                           ' 
            OKAY = 0                                       ' High RESET PIN on SIM800L board
            HRSIn {10000,Main},Wait("SMS Ready")           ' If OK go ahead, if ERROR try again
    
    Pin_ok:                                              
            GoSub Init                                     ' Init SIM card
            GoSub Clear_Vars                               ' Clear variables
            PEIE = 1                                       ' Enable peripheral ints
            RCIF = 0                                       ' Just to be sure that the int flag is clear
            RCIE = 1                                       ' Enable interrupts from USART receiver        
            While GIE = 0: GIE = 1: Wend                   ' Off we go......
    
    
    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Main Loop~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Main_Loop:
    
    While 1 = 1
             Clrwdt
             While GIE = 0: GIE = 1: Wend                   ' Global ints ON ......
             High Stat                                 ' LED is OFF
                If instr = "CLIP" And num = "XXXXXXXXXX" Then                         ' If "+" received then...
                    While GIE = 1: GIE = 0: Wend            ' Switch off interrups to communicate freely with SIM800L
    hangup:
                    HRSOut "ATH\r\n"                        ' Hang Up
                    HRSIn {1000,hangup},Wait("OK")
                    HRSOut "Get it...   \r\n"               ' Print on terminal
    readbook:
                    HRSOut "AT+CPBR=1,250\r\n"              ' Read the phonebook
                    HRSIn {1000,readbook},Wait("OK")
                    GoSub Clear_Vars
                    PORTA.1 = 1
                    DelayMS 1200                            ' Blink "Received OK" LED
                    PORTA.1 = 0
                    dummy = 0      
                EndIf
            
    
             
    Wend
    
                                                            '
    Init:                                                   '
            Low PORTA.2                                     '
            HRSOut "ATE0\r\n"                               '
            HRSIn {1000,Init},Wait("OK")                   '
    step2:                                                  '
            HRSOut "AT+CSQ\r\n"                             '
            HRSIn {1000,step2},Wait("OK")                  '
    step3:                                                  '
            HRSOut "AT+CPBS=\"SM\"\r\n"                     '
            HRSIn {1000,step3},Wait("OK")                  '
    step4:                                      
            HRSOut "AT+CLIP=1\r\n"                          '
            HRSIn {1000,step4},Wait("OK")                  '
            HRSOut "AT&W\r"                                 '
            HRSIn {1000,Init},Wait("OK")                   '
            HRSOut "Settings DONE !\r\n"                    '
            DelayMS 1000                                    '
            High PORTA.2                                    '
            
    Return                                                  '
    Clear_Vars:                                             '
            i = 0                                           '
            d = 0                                           '
            a = 0                                           '
            Clear dummy                                     '
            PORTA.1 = 0
    Return                                                  '
    
    End
    Thanks,
    Steve
    Last edited by John Drew; 18th July 2017 at 13:04. Reason: removed phone number

  8. #8
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,188
    Thumbs Up
    Received: 217
    Given: 78
    Total Downloaded
    1.50 GB

    1 Not allowed!

    Default Re: GSM communication with SIM900

    To make the receive buffer act as a string, simply make it a string. Remember, a String is, essentially, a byte array with a null termination.

    Dim bModemReceiveBuffer as String * 250

    To extract info from the receive string use the Left$, Mid$, or Right$ commands, or a simple comparison of the whole response. For example to check a SIM, send the "AT+CPIN?" command, and wait for the response "+CPIN: READY". The response may vary for different modems.

    If bModemReceiveBuffer = "+CPIN: READY" Then
    ' SIM is ready
    EndIf

    To extract a piece of data from a response, one way is to take the responding string from the command. For example "AT+CPIN?", then blank out the characters not wanted, then trim the left spaces to leave the result. Here's a simple routine that will trim spaces from the left of a string for an enhanced 14-bit core device:

    Code:
        Dim Trim_tFlag As Bit   
        Dim Modem_bTemp As Byte    
        
        Dim wFSR0 As  FSR0L .Word     ' Make a 16-bit SFR from FSR0L/H
        Dim MyFSR1 As  FSR1L .Word    ' Make a 16-bit SFR from FSR1L/H
    '------------------------------------------------------------------------------------------------------------------------------------
    ' Trim any spaces from the beginning of a RAM string
    ' Input     : pSourceString 
    ' Output    : pDestString
    ' Notes     : Uses indirect addressing for the strings
    '
    $define Trim_Left(pSourceString, pDestString) '
        wFSR0 = AddressOf(pSourceString) '
        wFSR1 = AddressOf(pDestString)   '
        GoSub _Trim_Left
        
    _Trim_Left:
        Trim_tFlag = 0
        While  INDF0  <> 0
            Moviw INDF0++
            Modem_bTemp =  WREG 
            If Trim_tFlag = 1 Then
                 WREG  = Modem_bTemp
                Movwi INDF1++
            ElseIf Modem_bTemp <> " " Then
                Trim_tFlag = 1
                 WREG  = Modem_bTemp
                Movwi INDF1++
            EndIf
        Wend
         INDF1  = 0
        Return
    To demonstrate the above routine:

    Code:
        Device = 16F1939
        Declare Xtal= 32
    
        Declare Hserial_Baud = 9600
    
        Dim MyString As String * 30 = "    Hello World"
    
        Trim_Left(MyString, MyString)
        HrsoutLn MyString
    The spaces from the beginning of MyString are now removed.

    A simple demo is to remove the "+CPIN:" text from the "+CPIN: READY" response:
    Code:
    ' Replace the "+CPIN:" characters with spaces
    '
        bModemReceiveBuffer#0 = 32
        bModemReceiveBuffer#1 = 32
        bModemReceiveBuffer#2 = 32
        bModemReceiveBuffer#3 = 32
        bModemReceiveBuffer#4 = 32
        bModemReceiveBuffer#5 = 32
    '
    ' Remove the leading spaces, leaving only the response
    '
        Trim_Left(bModemReceiveBuffer, bModemReceiveBuffer)
    A way to extract comma delimited responses is to write a routine that counts the commas and removes the texts in-between them.

    Always remember, if interfacing with the modem is for critical purposes, it is very important to make sure commands are sent and received correctly, so more controlled receive routines are very important. Modems are absolutely dreadful sometimes, and that comes from the fact that they are built by committee over a long period of time, and things inside have not been remembered when new bits are added, so they are more complex than was originally intended, and they are very, very buggy. I know this for a fact, as I have worked with various modems for over 10 years.
    Last edited by Les; 18th July 2017 at 12:59.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  9. #9
    Junior Member RSteve's Avatar
    Join Date
    Aug 2008
    Posts
    9
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    183.06 MB

    0 Not allowed!

    Default Re: GSM communication with SIM900

    Thank You, Les.
    The Trim routine works perfectly.

    P.S.
    Thanks John.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. syntaxis problem with HRSout and AT commands SIM900
    By pe1pme in forum Absolute Beginners Section
    Replies: 6
    Last Post: 24th August 2015, 04:07
  2. Serial communication with SIM900 module
    By kgronerc in forum Absolute Beginners Section
    Replies: 3
    Last Post: 23rd August 2015, 14:34
  3. GSM Dates
    By Peter Truman in forum GSM / SMS
    Replies: 8
    Last Post: 15th October 2012, 00:08
  4. gsm
    By ADLIN SYSTEMS in forum GSM / SMS
    Replies: 3
    Last Post: 5th September 2011, 20:17
  5. pic to gsm phone communication
    By shani in forum GSM / SMS
    Replies: 1
    Last Post: 25th September 2010, 01:19

Tags for this Thread

Posting Permissions

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