Page 1 of 1

How to send ASCII char while using GSM component.

Posted: Fri Jan 17, 2020 12:42 am
by sysprofessional
Hi,
I need to send ASCII character while using " GSM (EB066,Generic AT) " component in FC6.
there is two parameters in 'SendCommand' macro.
First parameter just used for string only,while 2nd parameter ' SendCR ' is a Byte variable,
SendCR=0 for disable ,and 1 or may be greater then 0 will enable SendCR, and it will send ASCII 13 to serial port.
how can send any other char ??????
Script option in component property also working as string.
SendMessage macro sending Char 26 (^z) over serial.
is it possible to send char 26 over serial if using Sendcommand?

Re: How to send ASCII char while using GSM component.

Posted: Fri Jan 17, 2020 3:02 am
by mnf
Hi,

You should be able to add the value to the string as an escape sequence.

Code: Select all

"\xhh"
can be used to add a hex character constant or "\nnn" adds the value as octal, e.g. \101

You can also add multiple characters "\x1a\x1a" would be two ctrl z characters.

Similarly can use for single characters using '\xhh' though less useful.

See for examplehttps://en.m.wikipedia.org/wiki/Escape_sequences_in_C

Note that you need to use hex or octal not decimal values.

You could also add the characters to a string using

Code: Select all

.s[0] = 26
for example - don't forget a 0 terminator if you use this approach..

Martin

Re: How to send ASCII char while using GSM component.

Posted: Sat Jan 18, 2020 3:03 pm
by sysprofessional
Thanks for help, its working nicely ,
btw i was using "\0x1a" that's not working,but "\x1a" working perfectly.

Re: How to send ASCII char while using GSM component.

Posted: Sat Jan 18, 2020 4:11 pm
by mnf
Glad to hear it's working.

The leading 0 as in .x = 0x25 is to let the compiler know that a number is coming - otherwise it would treat the value as a variable name (or identifier) - in this case x25.

Martin