+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Member level 2
    Points: 774, Level: 6

    Join Date
    Apr 2012
    Posts
    42
    Helped
    0 / 0
    Points
    774
    Level
    6

    How to send at+cpms="me","me","me" to serial port

    HI
    I am using AT89S52 to read a sms which attached to motorola C168. I need to transmit AT+CPMS="ME","ME","ME" to serial port as below, How can I do it?
    Code:
    void SMSString(char*text) ;
    
    SMSString("AT\r"); // AT commands to initialize gsm modem
    delay(50);
    
    SMSString( "ATe0\r"); // turn off echo
    delay(50);
    
    SMSString( "AT+CPMS="ME","ME","ME"\r"); // select memory
    delay(50);
    
    SMSString( "AT&W\r"); // save settings
    delay(50);
    
    SMSString( "AT+CMGF=1\r"); // select text mode for sms
    delay(50);
      
    SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms
    When I am doing this in KEIL uVision3, there is an error called "error c141: syntax error near 'ME' ". How can I transmit to serial port without any trouble?

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 4
    Points: 6,918, Level: 19
    Achievements:
    Created Blog entry Created Album pictures 7 years registered
    alexxx's Avatar
    Join Date
    Apr 2011
    Location
    Greece
    Posts
    1,013
    Helped
    278 / 278
    Points
    6,918
    Level
    19
    Blog Entries
    2

    Re: How to send at+cpms="me","me","me" to serial port

    It is propably because you need to place a backslash (\) before a quotation mark (""). This is the way to keep your compiler happy about embodying quotation marks inside a declared string.
    In real life you would say AT+CPMS="ME","ME","ME", but in C it must be like:

    unsigned char str[] = "AT+CPMS=\"ME\",\"ME\",\"ME\"";

    In this way the compiler understands that a string is not terminated with the quotation mark, but this quotation mark is actually part of the string.



  3. #3
    Member level 2
    Points: 774, Level: 6

    Join Date
    Apr 2012
    Posts
    42
    Helped
    0 / 0
    Points
    774
    Level
    6

    Re: How to send at+cpms="me","me","me" to serial port

    Hi,
    Thanks for your help. I works now. I have another problem, that is when I am sending a SMS using AT command (AT+CMGS="tel no" message and ctrl+z) it will successfully send. but I cant read the received sms. It will show as . What is wrong with my AT commands?



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 4
    Points: 6,918, Level: 19
    Achievements:
    Created Blog entry Created Album pictures 7 years registered
    alexxx's Avatar
    Join Date
    Apr 2011
    Location
    Greece
    Posts
    1,013
    Helped
    278 / 278
    Points
    6,918
    Level
    19
    Blog Entries
    2

    Re: How to send at+cpms="me","me","me" to serial port

    I cant read the received sms. It will show as
    Where do you see this "unreadable format"? Do you use a treminal software? This is strange in any case, because sms is received as string.



  5. #5
    Member level 2
    Points: 774, Level: 6

    Join Date
    Apr 2012
    Posts
    42
    Helped
    0 / 0
    Points
    774
    Level
    6

    Re: How to send at+cpms="me","me","me" to serial port

    I saw this through my phone. It will display as unreadable format.



  6. #6
    Advanced Member level 4
    Points: 6,918, Level: 19
    Achievements:
    Created Blog entry Created Album pictures 7 years registered
    alexxx's Avatar
    Join Date
    Apr 2011
    Location
    Greece
    Posts
    1,013
    Helped
    278 / 278
    Points
    6,918
    Level
    19
    Blog Entries
    2

    Re: How to send at+cpms="me","me","me" to serial port

    OK, now it makes sence. This means that you are not sending ASCII characters from the GSM or there is some violation of the send sms command. Double check the code that sends the sms payload from your MCU to the GSM.
    If you can debug the code, it would be really usefull to stop before you send the sms and check the contents of the serial output buffer.



    •   AltAdvertisement

        
       

  7. #7
    Member level 2
    Points: 774, Level: 6

    Join Date
    Apr 2012
    Posts
    42
    Helped
    0 / 0
    Points
    774
    Level
    6

    Re: How to send at+cpms="me","me","me" to serial port

    How can I check whether I an sending ASCII characters or not? How can I set up the basic configurations to send ASCII characters from my GSM module (Motorola C168).



--[[ ]]--