Escaping carriage return (\x1A) ?

Hello Everyone,

I'm working on a project that sends SMS via a SIM 800 gsm module.
It needs to send Greek Text as well, so I've enabled the CMGHEX mode and it works fine.

However the problem comes with the Greek leter Ξ, which in the GSM Alphabet has the value of 20 (hex: 1A).

So if I need to use that in a sentence and replace it with \x1A, it truncates the message at that character, as the \x1A is the carriage return in Arduino, so it sends the message as soon as it prints that character to the gsm Serial interface.

How can I send that letter without triggering the CR ?

Can I escape it somehow?

If not, is there any other option?

Thanks!

0x1A is not a Carriage Return, nor does it equate to 20 (you don't say in which base)

Can you please post the program that is causing your problem or a smaller, but complete program that illustrates it ?

Thank you for the fast answer.

My mistake of not describing this correctly.

So the \x1A sequence is the CTRL+Z equivalent, which you need to send to the GSM modem in order to send an SMS message.

So the format is

gsm.serialPrint("AT+CMGS=\"+30699999999\");

//Then send the message to the gsm serial
gsm.serialPrint("Test message");
//send the CTRL+Z to send it
gsm.serialPrint("\x1A");

My problem is that I need to send something like this:

gsm.serialPrint("AT+CMGS=\"+30699999999\");

//Then send the message to the gsm serial
gsm.serialPrint("TO KAPOY\x14I \x1A""EKINH\x18""E);
//send the CTRL+Z to send it
gsm.serialPrint("\x1A");

Where \x1A is the letter Ξ in the GSM Alphabet

And my problem is that this message will truncate at the \x1A (Ξ) character.
Somehow, I need to escape this character in order to send it, by I don't know how.

UKHeliBob:
0x1A is not a Carriage Return, nor does it equate to 20 (you don’t say in which base)

Can you please post the program that is causing your problem or a smaller, but complete program that illustrates it ?

The “0x” prefix means it’s hex. And, 0x1A is decimal 26 (ASCII Control-Z).

Can you use Serial.write(0x1A); or Serial.write(26); ?

...R

lefteris:

gsm.serialPrint("\x1A");

Try this:

gsm.serialPrint ((uint8_t)('Z'-'@'));

// --- or ---

gsm.serialPrint ((uint8_t) 0x1A);

Robin2:
Can you use Serial.write(0x1A); or Serial.write(26); ?

...R

Since the syntax of the OP's function is "[b]gsm.[color=blue]serialPrint[/color]()[/b]", I suspect that "serialPrint" is a function in his GSM library and he's not using the core [b]Serial.print/write[/b] (although I wonder if "[b]gsm.print()[/b]" or "[b]gsm.write()[/b]" would work?)

the gsm, is the softwareSerial for the Sim800

//SIM 800 PINS
#define SIM800_TX_PIN 11
#define SIM800_RX_PIN 10
SoftwareSerial gsm(SIM800_TX_PIN,SIM800_RX_PIN);

If I write to the gsm serial this: Serial.write(0x1A); or Serial.write(26);
it will do the same thing.
Sent the sms message then.

My goal is not to send the sms message when sending the greek character

krupski:
The "0x" prefix means it's hex. And, 0x1A is decimal 26 (ASCII Control-Z).

I know what it is but I was pointing out that it was not what the OP said it was.

krupski:
Try this:

gsm.serialPrint ((uint8_t)('Z'-'@'));

// --- or ---

gsm.serialPrint ((uint8_t) 0x1A);

Both of these are just sending the ascii code (26) to the SMS instead of the letter
Thanks for the suggestion though!

Ok, seems that this is impossible by the SIM800 design.
I was looking again at the AT Commands manual and noticed this:

Enable to send SMS varying from 0x00 to 0x7f except 0x1a and 0x1b under text mode and GSM character set

So basically the greek Ξ character is unavailable in this mode and only solution is to probably use PDU mode, which I don't want as it increases the sketch a lot.