Asked • 06/05/19

Decoding Simulink's UDP Packets in Python?

I have a Simulink model sending data via UDP to another program (Blender) where I can receive the packets, but I have not been able to figure out how to correctly decode them. In the Simulink model I just have it sending a value that is based upon a sine wave, nothing fancy, just a single value like 1.452 or something. In Blender I have it spitting out the data it receives from the packet, and I'm receiving stuff like: b'<\\xa6ya\\x05\\x93\\xe3?' I have no idea how to decode this. It seems to have some hex values, but beyond that I'm lost. I'm not even sure what all this data contains. Is it just the value from Simulink, or does it contain information regarding things like the sender and receiver IP addresses, ports, etc...? **UPDATE**: I updated the Simulink model to transmit a constant value via UDP for debugging/investigation. The value is 0.5234, and the data that my Python script is spitting out is: b'\\xab>W[\\xb1\\xbf\\xe0?' Which, when converted into hexadecimal reads (using hexlify): b'ab3e575bb1bfe03f' How would I extract/decode 0.5234 out of that? Thanks for any help!

1 Expert Answer

By:

Stewart H. answered • 06/08/19

Tutor
5.0 (751)

Experienced Python Programmer for Data Science and Machine Learning

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.