UDP message handler, struct to hex convert function

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi everyone,

How can I do a check on received UDP message and react to it.
For example if the message was “1234” then do task 1
If the message was “4321” do task 2
Else do task 3.
The conditions are not so many. The messages are coming from a PC and I know the messages.
First idea came to my mind was to covert the struct to hex and compare the hex equivalent like if (hex (message) == hex(1234)) { … }
But I don’t know if it will work or not. And also I could not find the command to convert the struct into the hex.
Does anybody know which command I can use? Do I need to include any header file as well?

Thanks in advance for support.

sincerely,

H. Hafezi
0 Likes
0 Replies