HTTPClient Onkyo receiver control

bartm
2020-05-12
2020-05-15
  • bartm

    bartm - 2020-05-12

    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.

     
  • quirzo

    quirzo - 2020-05-13

    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
  • bartm

    bartm - 2020-05-13

    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
  • quirzo

    quirzo - 2020-05-14

    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:

        Data : ARRAY[0..200] OF BYTE := [73, 83, 67, 68, 0(*and so on*)];
    
     
  • bartm

    bartm - 2020-05-14

    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.

     
  • quirzo

    quirzo - 2020-05-14

    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

    73 83 67 80 0 0 0 16 0 0 0 8 1 0 0 0 33 49 80 87 82 48 49 13
    

    you will see in wireshark something like

    55 51 32 56 51 32 54 55 32 56 48 32 48 32 48 32 48 32 49 54 32 48 32 48 32 48 32 56 32 49 32 48 32 48 32 48 32 51 51 32 52 57 32 56 48 32 56 55 32 56 50 32 52 56 32 52 57 32 49 51 
    

    Where 7 = 55, 3 = 51 and so on.

     
  • bartm

    bartm - 2020-05-14

    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?

     
  • quirzo

    quirzo - 2020-05-15

    Could you please post your current code

     

Log in to post a comment.