Hi Community,
I'm trying to save complex data from a block into a file, in order to
process the information later on. My code is very simple, as shown
bellow:
//Definition of values
std::vector<float> complex_values(4);
complex_values[0]=(-0.707,-0.707);
complex_values[1]=(0.707,-0.707);
complex_values[2]=(-0.707,0.707);
omplex_values[3]=(0.707,0.707);
myfile.open ("/home/usrpvm/Desktop/examples/binary_complex");
myfile <<(char*)&complex_values[0];
myfile <<(char*)&complex_values[1];
myfile <<(char*)&complex_values[2];
myfile <<(char*)&complex_values[3];
When I finish, I check my values with hexdump command:
hexdump binary_complex -v -e ' 2/4 "%10f "' -e '"\n"'
-0.707000 -0.707000
0.707000 0.707000
-0.707000 0.707000
0.707000 0.707000
0.707000 0.707000
As you can see, there are more values that I'm saving and there are some
values missing. I think I am doing something wrong when I save the
values.
Anyone can point me to the right direction?
Thanks for your time,
Jose.
on 2012-10-30 11:25
on 2012-10-31 07:50
On 10/30/2012 03:24 AM, Jose Torres Diaz wrote: > complex_values[2]=(-0.707,0.707); > omplex_values[3]=(0.707,0.707); > > myfile.open ("/home/usrpvm/Desktop/examples/binary_complex"); > > myfile <<(char*)&complex_values[0]; > myfile <<(char*)&complex_values[1]; > myfile <<(char*)&complex_values[2]; > myfile <<(char*)&complex_values[3]; You are casting it into a char * that isnt null terminated. > As you can see, there are more values that I'm saving and there are some > values missing. I think I am doing something wrong when I save the values. > > Anyone can point me to the right direction? > > Thanks for your time, > > Jose. take a look at uhd/host/examples/rx_samples_to_file.cpp http://code.ettus.com/redmine/ettus/projects/uhd/r... -josh
on 2012-10-31 12:27
Hi Josh, Thanks for your answer, I followed the provided example and it's working correctly. Cheers, Sent from my iPhone
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.