Skip to content

Instantly share code, notes, and snippets.

@meise
Created January 27, 2016 16:36
Show Gist options
  • Save meise/6d3e5c91e5003da0fd76 to your computer and use it in GitHub Desktop.
Save meise/6d3e5c91e5003da0fd76 to your computer and use it in GitHub Desktop.
extract floats from gr message queue without numpy
msg = tb.msgq_out.delete_head()
msg_string = msg.to_string()
samples = np.fromstring(msg_string, dtype='float32')
# pull from message queue
msg = tb.msgq_out.delete_head()
msg_string = msg.to_string()
samples = []
# extract floats from msg string
# it is slow. very slow! :/
for i in range(0,len(sample),4):
# unpack sample to have a tuples
unpacked = struct.unpack_from('f', sample[i:i+4])
samples.append(unpacked[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment