OpenViBE forum

The OpenViBE community
It is currently Sun May 26, 2019 11:37 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TCP Writer
PostPosted: Tue May 07, 2019 3:14 pm 
Offline

Joined: Thu Mar 07, 2019 8:05 am
Posts: 8
What kind of encoding is the raw data of TCP Writer? I try to decode it with a Python script. "utf-8" and "utf-16" did not work.

edit: I figured out what I wanted.

You can index the data received ("recv" in Python):

Code:
data = socket_from_tcp_writer.recv(buf_size) # important to set up socket before
len(data) # = 8*number channels*chunk size (e.g. 1 channel, 4 samples per chunk --> 32)


Now, every "chunk" of 8 numbers in this list has to be converted to "double" variable type in Python:
(sadly the indentation was lost) Moderator Edit : the code tag instead quote tag for code.^^

Code:
# buf_size_sc: samples per chunk set in scenario or acquisition server
for factor in range(buf_size_sc):
    # append to list
    to_convert = []
    for i in range(8):
        to_convert.append(data[factor*8 + i])
    # convert
    converted = bytearray(to_convert)
    # readout actual number
    floatval_tuple = struct.unpack('d', converted)
    floatval = floatval_tuple[0]
    chunk_vals.append(floatval)


chunk_vals is now a list containing all floating point values of the chunk.


Top
 Profile  
Reply with quote  
 Post subject: Re: TCP Writer
PostPosted: Thu May 09, 2019 10:28 am 
Offline

Joined: Wed Oct 31, 2018 9:14 am
Posts: 79
I don't understand your edit^^, your problem is solved ?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maƫl Soucaze.