Hi,
I have a problem when I use UDP_RECEFROM command to store and decode a udp message.
I try to send a string of Hex code like "00 0a 02 ff" to E-controller robot via UDP. The Hex code is sent from another machine to tell the robot something based on its message rules.
The issue is the received string can only recognize ASCII characters, like "a","A","1" etc. The other bytes which not equal to characters are saved incorrectly.
When I send "41 42 43 44", the robot received "ABCD". len($rcv)=4; asc($mid($rcv,1,1))=65; asc($mid($rcv,2,1))=66; asc($mid($rcv,3,1))=67; asc($mid($rcv,4,1))=68; They are correct.
When I send "01 02 41 42", the robot received "". Length of string=4; asc($mid($rcv,1,1))=0; asc($mid($rcv,2,1))=0; asc($mid($rcv,3,1))=0; asc($mid($rcv,4,1))=0; They are incorrect.
So how can I get the correct message ? or is there a way to decode the correct message byte by byte from the string ?