I want to communicate with a Domino Industrial Printer using its Codenet protocol.
The printer wants a series of Hexadecimal characters with no spaces or '00' characters.
Because of that i chose the option to make the prefix and subfix for my code in a string.
I have variable data in another string.
With a complete program of a lot of CONCAT functions i eventually get the format of code that the printer accepts ( tested it with the hercules tool).
Hercules String : 1B4F513030311B7532626C61636B04
The problem is : Codesys adds automatically 'code' to the code to show it is a string.
Codesys string : '1B4F513030311B7532626C61636B04'
The printer does not understand this. My idea is to convert the string datatype to an LWORD.
I have no idea how to do this. I random types in STRING_TO_DWORD, as return i get 0. That didn't worked. Also on internet the explenations around string converting in codesys are very limited.
If there in anyone who can explain me how to do it, i would appreciate it a lot !
Thank you!
Last edit: bertcom 6 days ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The '' characters in Codesys are there only to indicate it is a STRING type.
They are not actually added to the string, maybe you are adding them unintentionally in the concat function?
You can send your data from Codesys to Hercules to verify...
Another option is to send the data as an array of bytes instead of a string, with every byte representing 1 ASCII character. https://www.ascii-code.com/
This way you are 100% sure Codesys is not adding any unwanted characters.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I guess that the printer expects to receive an array of byte values. So where it is described that it expects to receive:
Hercules String : 1B4F513030311B7532626C61636B04
it actually expects to receive an array of bytes with the values 1B,4F,51,30,30, etc.
So what you can do is create an array of bytes and assign the byte value to each item in the array:
Then with the serial communication (or TCP/IP?) you can send a message with the reference to the array (abyToSend) and the number of bytes to send (15 bytes for the string you gave as example).
Good afternoon.
I want to communicate with a Domino Industrial Printer using its Codenet protocol.
The printer wants a series of Hexadecimal characters with no spaces or '00' characters.
Because of that i chose the option to make the prefix and subfix for my code in a string.
I have variable data in another string.
With a complete program of a lot of CONCAT functions i eventually get the format of code that the printer accepts ( tested it with the hercules tool).
Hercules String : 1B4F513030311B7532626C61636B04
The problem is : Codesys adds automatically 'code' to the code to show it is a string.
Codesys string : '1B4F513030311B7532626C61636B04'
The printer does not understand this. My idea is to convert the string datatype to an LWORD.
I have no idea how to do this. I random types in STRING_TO_DWORD, as return i get 0. That didn't worked. Also on internet the explenations around string converting in codesys are very limited.
If there in anyone who can explain me how to do it, i would appreciate it a lot !
Thank you!
Last edit: bertcom 6 days ago
I don't fully understand the issue, but if the encoding is a problem you can try testing with WSTRING datatype instead of STRING.
https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_datatype_wstring.html
@trusty-suire,
The problem is not encoding. The problem is that codesys ands ' ' to the string. And the printer can't handle these character.
@trusty-suire,
The problem is not encoding. The problem is that codesys ands ' ' to the string. And the printer can't handle these character.
Hi,
The '' characters in Codesys are there only to indicate it is a STRING type.
They are not actually added to the string, maybe you are adding them unintentionally in the concat function?
You can send your data from Codesys to Hercules to verify...
Another option is to send the data as an array of bytes instead of a string, with every byte representing 1 ASCII character. https://www.ascii-code.com/
This way you are 100% sure Codesys is not adding any unwanted characters.
Hi rmaas,
Do you have any explenation how to send it to Hercules?
Thank you!
I guess that the printer expects to receive an array of byte values. So where it is described that it expects to receive:
Hercules String : 1B4F513030311B7532626C61636B04
it actually expects to receive an array of bytes with the values 1B,4F,51,30,30, etc.
So what you can do is create an array of bytes and assign the byte value to each item in the array:
Then with the serial communication (or TCP/IP?) you can send a message with the reference to the array (abyToSend) and the number of bytes to send (15 bytes for the string you gave as example).
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3