I'm struggling to sent a string in byte format to an Onkyo receiver.
The idea was to use the httpclient fb and sent the wstring sTest: WSTRING(200):="73 83 67 80 0 0 0 16 0 0 0 8 1 0 0 0 33 49 80 87 82 48 49 13"; to it
Somewhere in the process I need to do a hex to byte because it should be sent as bytes. Here I'm stuck.
I can control it by a powershell script (attachment), but I cannot convert this script to codesys.
Use STRING instead of WSTRING so you get directly values as bytes. WSTRING is in unicode so it uses 2 bytes for each character and STRING uses one byte for each character.
π
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the support.
Still no success with the format, I need to sent one "0", $0 isn't accepted and $00 doest not work.
When I check the traffic with wireshark on the IP address, it is totally different compared to the powershell script.
Last edit: bartm 2020-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh sorry. I just realized that you have bytes you want to send in that WSTRING, not characters? If so, then that code can't work as the 73 = character seven and three, not byte value 73.
Then you need to create an array of bytes and place the data in there:
so the Data array should be sent by the httpclient? I have no errors, but when I check the traffic with wireshark or tcpdump it is not like the traffic generated from the powershell script.
I've tried also the oscat buffer_to_string function and sent the resulting string, but I think the "0"s are causing trouble, not sure however because this is unknown territory for me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm quite lost in this mather, wireshark does not show the above at all with the data sent from codesys.
When I do it with the powershell script, I have exactly the same result as above.
should I use the buffer_to_String function from oscat to extract a string from the array of bytes?
And sent this with httpclient?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm struggling to sent a string in byte format to an Onkyo receiver.
The idea was to use the httpclient fb and sent the wstring sTest: WSTRING(200):="73 83 67 80 0 0 0 16 0 0 0 8 1 0 0 0 33 49 80 87 82 48 49 13"; to it
Somewhere in the process I need to do a hex to byte because it should be sent as bytes. Here I'm stuck.
I can control it by a powershell script (attachment), but I cannot convert this script to codesys.
Use STRING instead of WSTRING so you get directly values as bytes. WSTRING is in unicode so it uses 2 bytes for each character and STRING uses one byte for each character.
Thank you for the support.
Still no success with the format, I need to sent one "0", $0 isn't accepted and $00 doest not work.
When I check the traffic with wireshark on the IP address, it is totally different compared to the powershell script.
Last edit: bartm 2020-05-13
Oh sorry. I just realized that you have bytes you want to send in that WSTRING, not characters? If so, then that code can't work as the 73 = character seven and three, not byte value 73.
Then you need to create an array of bytes and place the data in there:
so the Data array should be sent by the httpclient? I have no errors, but when I check the traffic with wireshark or tcpdump it is not like the traffic generated from the powershell script.
I've tried also the oscat buffer_to_string function and sent the resulting string, but I think the "0"s are causing trouble, not sure however because this is unknown territory for me.
Yes, use that byte array to send data. The data was different because if your string has ASCII characters (or WSTRING has unicode).
If you have STRING of
you will see in wireshark something like
Where 7 = 55, 3 = 51 and so on.
I'm quite lost in this mather, wireshark does not show the above at all with the data sent from codesys.
When I do it with the powershell script, I have exactly the same result as above.
should I use the buffer_to_String function from oscat to extract a string from the array of bytes?
And sent this with httpclient?
Could you please post your current code