Can I send CR and/or LF using OUTPORT?

Can I send CR and/or LF using OUTPORT?
none 0.0 0
  • HMI Model: cMT3072XH2
  • EasyBuilder Pro Version: 6.09

I have a device that uses a simple ASCII protocol for data retrieval.

The command structure is:
#[UNIT] [COMMAND] [CRLF][LF]

For example to request the status of the unit, I need to send:
#01 STATUS CRLFLF

The CRLF (Carriage Return + Line Feed) and the LF (Line Feed)are the end of parameter/packet codes after which the unit will respond.

How can I send the 0D+0A for CR+LF and the 0A for the line feed. The OUTPORT instruction only supports CHAR type data I can find no way to set a string to 0D or 0A.

Thanks!

Hi @rwlewis,

Thank you for contributing to our forum! That is an excellent question, the way in which I would append a [CR] + [LF] + [LF] to your command would be as follows:

Note: Please make sure that the “command” array has enough space to accommodate these 3 termination characters in addition to the [UNIT] and [COMMAND].

Thanks!

After posting I had worked out a way to send the CF and LF by initializing separate variables with the 0x0D and 0X0A values and then stringing together multiple OUTPORT instructions to send them one at time following the [UNIT] and [COMMAND].

The syntax/method for initializing the array using {…} is much more efficient!

My caveman solution:
image

1 Like

Wonderful! I’m happy to see that you’ve found another solution. Thank you for sharing!!