Using UDP send&receive data

Jeff_wu
Jeff_wu Altair Community Member
edited April 2023 in Community Q&A

I try to use UDP to communicate with the device and Embed but i can't send and receive full character Can someone tell me how to set? Thank you!

imageIt works on third-part UDP test software.

Answers

  • Sreejith_21826
    Sreejith_21826 New Altair Community Member
    edited April 2023

    Hi Robbert

    Data in UDP will be packed with 8bit length. 

    if you are sending a 2byte value 255, it will be sending 0xff. For 500 -> 1F4 

    If you want to send a constant string, go ahead with a flag value. for example 0x55 for "LED On" and 0xAA for "LED Off". so you dont need to pack the full string into UDP packet and decode at the receive end.

    It's all depend on the use case.

    "LED has been turn on" If you want to send this string you need to send each character ascii value. 
    0x4C 0x45 0x44 0x20 0x68 0x61 0x73 0x20 0x62 0x65 0x65 0x6E 0x20 0x74 0x75 0x72 0x6E 0x20 0x6F 0x6E

    connect each character to single byte pin and decode at the receive end.

    Currently we dont, provide a String dropdown option in UDP Write/Read block. Packing string size will confuse the user(space also consider as one character ' ' 0x20)  and need to extract properly at receive end.

    Attached one diagram for your reference.

     

    Regards

    Sreejith