View Single Post
  #2  
Old 02-12-2008, 03:09 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
1) If you want to read in binary numbers in Python you will need to use the struct module. Have a look at the Python documentation for detailed info. Here is a basic usage that will read in 4 binary floating point values from a data string:
Code:
import struct
.
.
.

#Read data from socket
s = InSocket.recv(PACKET_SIZE)

#Unpack binary data into 4 floating point numbers
data = struct.unpack('ffff',s)

#Print floating point list
print data
2)At what frequency are you sending data in MATLAB. If you send data faster than it can be read, then some packets might be lost. Vizard's graphics loop runs at your monitor refresh rate, which is usually 60Hz. Either way, you can save the time when a packet is received and compare it to the previous receive time. This will give you a rough estimate on the time between packets. Example:
Code:
recv_time = viz.tick()
.
.
.
#Code that should be called when data is received
global recv_time
now = viz.tick()
print '%.2f ms between packets' % (now-recv_time)*1000.0
recv_time = now
Reply With Quote