Function diagram, string to AnyType
Hi, we are using the TCPWrite block of the tcpcommlib which has an input of AnyType (see attachment). My assumption was that we can connect anything we want to this input, set NoOfBytesToSend to 0 and BytesPerItem to 2 (since each char is 2 bytes) and the block would itself figure out how/what to send.
But it doesn't work as expect, the error/status of the block indiciates problems (since we never see status code 1).
While connecting an integer value directly to the Sd port (AnyType) works just fine.
Are we required to turn the string from a string into a type of AnyType? If that is the case suggestions are welcome as to how.
Answers
As per the Help (select the TCPWrite Block and press F1 to open it), the Block only supports Variables that consist of Components of Dint or Dword Type:
The TCPWrite function block writes a struct of dints or dwords to a receiving device. [...]
Strings are converted to dint/dword using the function StringToASCIIStruct. [...]
so i suppose you need to insert the StringToASCIIStruct Block yourself, convert the String to a structured Variable with DInt components and connect only that Variable to the TCPWrite.
What Status Code Number do you get out from the TCPWrite Block in case of Error?
Add new comment