This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sending Ctrl+z over uart

I am interfacing the nrf2832 with the sim 808 module.

In order to be able to send a message I need to use Ctrl+z.

This should be entered as an escape sequence.

I have tried printf("\x1A"); but it doesn't work. How do I send Ctrl+z as an escape sequence?

  • I think that your problem is that you're passing a string rather than a character.

    Try 

    printf('\x1A');

  • When I put printf('\x1A')  it gives me a warning telling 'format string is not a string literal'.

  • Yes you're right, my mistake.

    I usually treat my data as binary and build them up in a buffer before sending.

    As far as I can tell it should work.

    Are you attempting to escape back to an AT-Command string?

    Do you need to place <CR><LF> after the CTRL-Z?

    Otherwise have you tried something like

    printf("%c", 0x1A);

  • Thank you for the response.

    AT+CMGS=<number><CR><message><CTRL-Z>  (This the format of the AT commands that has to be sent).

    printf("\r\nAT+CMGF=1\n");
    		nrf_delay_ms(5000);
    		printf("AT+CMGS=\"+919xxxxx22\"\r");
    		nrf_delay_ms(2000);
    		printf("Hello,Elecrow!");
    		nrf_delay_ms(1000);
            printf("%c", 0x1A);	// i tried this but its not working , i have put ctrl+z here 
    		nrf_delay_ms(1000);
    		printf("\r\nAT\r\n");
    		nrf_delay_ms(5000);

    the rest of the AT commands are giving proper return values 

  • I've just had a peek at the AT-Command manual for the SIM800 devices.

    It looks to me that your number is incorrectly entered. I think that it should be:

    		printf("AT+CMGS=\"919xxxxx22\", 145\r");
    

    +CMGS=<da>[, <toda>] <CR>text is entered <ctrl-Z/ESC

    <da> GSM 03.40 TP-Destination-Address Address-Value field in string format(string should be included in quotation marks); BCD numbers (or GSM default alphabet characters) are converted to characters of the currently selected TE character set (specified by +CSCS in 3GPP TS 27.007); type of address given by <toda>

    <toda> GSM 04.11 TP-Destination-Address Type-of-Address octet in integer format (when first character of <da> is + (IRA 43) default is 145, otherwise default is 129)

Related