1
votes

I have written a code to send data to serial port /dev/ttyACM0. Basically this is used with the GSM modem to send an SMS. The AT command to set the sms in memory and send it are

First I need to write the following in serial port "AT+CMGW=16\r"

Then write the following pdu converted message 069110090000F111000A9210299232900000AA03C8F40F and then send ctrl-z

I have issues with sending ctrl-z

say message = "069110090000F111000A9210299232900000AA03C8F40F" I have tried

strcat(message,"\x1A"); //Does not work
strcat(message,"\032"); //Does not work

I have even tried my hand at a function which adds a char to char*

void append(char *s,char c)
{
   int len = strlen(s);
   s[len] = c;
   s[len+1] = '\0';
}

append(message, '\032'); //Does not work
append(message, '\x1A'); //Does not work

I need to read the receive buffer of the port to check for the count Example +CMGW:4

And then write AT+CMSS=3\r to send the message.

Typing the above AT commands on minicom sends the SMS. But in C code I just cannot type ctrl-z.

Does anyone know how to go about it?

Any help is appreciated Thank you

1
Does it not append to the message or does it not send the ctrl-z? If it does not send the ctrl-z, have you checked whether you are short by one character in the sending code?cup
@cup It seems that it appends. I see a weird looking symbol next to message on my receive buffer data. But once ctrl-z is sent I need to also receive +CMGW:<count> OK. I do not receive this at all. I just see the above commands and a weird symbol next to message, nothing following it. So I assume ctrl-z is not sentgfernandes

1 Answers

1
votes

Well, It was my mistake. I generalized the size of the data sent to the serial port. I think since the sent size defined was larger, the values following the ctrl-z hex value 0x1A were garbage values. So my command could not save the sms in memory as it did not know the values following 0x1A meant. To solve this I used strlen to send the real size of the char * sent to the serial port.