Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Send a Value (Double) with TCP IP Client Server

2021-09-09
2021-09-09
  • David.sa198 - 2021-09-09

    Hello every one. I could send data with TCP IP client Server to the server. (Thanks to this forum)
    Now I have problem that i need to send a double value for example 70.0000 but server recieve it 70 not 70.000 Therfore it can not be detected by server.

    Clinet_Tx1         : ARRAY [0..gvlSetting.gc_wMaxTelegram] OF 
    BYTE;
    
    Clinet_Tx1[0] := 128;
    Clinet_Tx1[1] := 9;
    Clinet_Tx1[2] := 0;
    Clinet_Tx1[3] := 0;
    Clinet_Tx1[4] := 140;
    Clinet_Tx1[5] := 16;
    Clinet_Tx1[6] := 0;
    Clinet_Tx1[7] := 0;
    Clinet_Tx1[8] := 70;
    Clinet_Tx1[9] := 0;
    Clinet_Tx1[10] := 0;
    Clinet_Tx1[11] := 0;
    Clinet_Tx1[12] := 0;
    Clinet_Tx1[13] := 0;
    Clinet_Tx1[14] := 0;
    Clinet_Tx1[15] := 0;
    // 0...3 Massage.Header 
    // 4..7 Address
    //8 ..15 Value (8 Byte- Double precision)
    // Data uses little-endian format
    

    How can I fix it?

     

    Last edit: David.sa198 2021-09-09
  • Ton - 2021-09-09

    To convert this number to bytes you can use an Union.
    TYPE UN_Test :
    UNION
    dwValue: DWORD;
    arrValue: ARRAY[0..3] OF BYTE;
    END_UNION
    END_TYPE

     
    πŸ‘
    1

Log in to post a comment.