I'm trying to read encoded raw data from UDP and to pass it to my custom MEX file for decoding. Now what I get when I use fread to read data from my UDP port are doubles. Also, the documentation for udp/fread tells that
"By default, numeric values are returned in double precision arrays"
however, what it doesn't tell is how I can prevent this conversion and how to get the raw byte values instead. I have no use of floating values and would have to convert back in my MEX file, which would cause unnecessary overhead.
So, if I do something like this:
u = udp();
u.LocalPort = 3333;
fopen( u );
data = fread( u, 10, 'uint8' );
fclose( u );
... and send for example via this little Python script:
UDP_IP = "127.0.0.1"
UDP_PORT = 3333
MESSAGE = "Hello, World!"
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
...then, just as the documentation of udp/fread tells, the Matlab code treats input as uint8 and returns doubles. However, in contrast to the fread documentation for reading from files, the UDP version seems to have no understanding of * or => syntax to specify output types.
How can I prevent this conversion from uint8 to double?