How to send ASCII char while using GSM component.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Has thanked: 28 times
Been thanked: 4 times
Contact:

How to send ASCII char while using GSM component.

Postby sysprofessional » Fri Jan 17, 2020 12:42 am

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?

mnf
Valued Contributor
Valued Contributor
Posts: 638
Joined: Wed May 31, 2017 11:57 am
Has thanked: 58 times
Been thanked: 357 times
Contact:

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

Postby mnf » Fri Jan 17, 2020 3:02 am

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
These users thanked the author mnf for the post (total 4):
LeighM (Fri Jan 17, 2020 8:33 am) • Benj (Fri Jan 17, 2020 10:50 am) • medelec35 (Fri Jan 17, 2020 12:26 pm) • sysprofessional (Sat Jan 18, 2020 3:00 pm)
Rating: 20%
 

User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Has thanked: 28 times
Been thanked: 4 times
Contact:

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

Postby sysprofessional » Sat Jan 18, 2020 3:03 pm

Thanks for help, its working nicely ,
btw i was using "\0x1a" that's not working,but "\x1a" working perfectly.
These users thanked the author sysprofessional for the post:
Benj (Mon Jan 20, 2020 10:51 am)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 638
Joined: Wed May 31, 2017 11:57 am
Has thanked: 58 times
Been thanked: 357 times
Contact:

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

Postby mnf » Sat Jan 18, 2020 4:11 pm

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
These users thanked the author mnf for the post (total 2):
sysprofessional (Sat Jan 18, 2020 8:48 pm) • Benj (Mon Jan 20, 2020 10:51 am)
Rating: 10%