Jump to content
  • 0
Yevheniy B

Read IQ Data from a QVRT file

Question

2 answers to this question

Recommended Posts

  • 0

Just to add onto the previous answer, here is an example c++ program that parses a file and converts samples of a given stream to floating point numbers and then prints them to standard out:

#include <stdlib.h>     /* strtol */
#include <fcntl.h>
#include <iostream>

int main(int argc, char *argv[])
{
    //get parameters
    if (argc != 4) return -1;
    std::string inFile = argv[1];                   //input file
    int streamId = strtol(argv[2], NULL, 0);        //Radio: 1 is A, 2 is B
    long samplesToRead = strtol(argv[3], NULL, 0);  //num samples to read

    int infileHandle = ::open( inFile.c_str(), O_RDONLY | O_NOATIME ); //open file

    unsigned int buffer[1000]; //allocate buffer

    //start reading
    long count = 0;

    while (true)
    {
        //read in a packet
        ::read( infileHandle, &buffer[0], 4000 );

        //check packet type and stream ID (outlined in the WBT File Format Documentation)
        if ((((buffer[0] & 0x000000F0) >> 4) == 1 ) && ( ((buffer[1] & 0xFF000000) >> 24) == streamId ))
        {
            unsigned short* fixedPointSamples = (unsigned short*)&(buffer[4]); //point to the beginning of the data area
            for ( int i = 0; i < 995; i++ ) // 995 samples per packet
            {
                unsigned short Ival = fixedPointSamples[ i*2 ];       //get the fixed point I and Q
                unsigned short Qval = fixedPointSamples[ i*2 + 1 ];

                Ival = (Ival << 8) | (Ival >> 8); //convert from big endian to little endian
                Qval = (Qval << 8) | (Qval >> 8);

                //send to standard output
                std::cout << ( ( (float)(short)(Ival) ) / ( (float)32768.0 ) ) //convert fixed to float
                          << ", "
                          << ( ( (float)(short)(Qval) ) / ( (float)32768.0 ) ) //convert fixed to float
                          << "\r\n";

                count++;    //increment counter
                if (count >= samplesToRead)
                {
                    ::close( infileHandle );
                    return 0;
                }
            }
        }
    }
    return 0;
}

It behaves in the following manner:

./QVRT2IQ bonly.qvrt 2 5
0.104431, -0.158569
0.104523, -0.158661
0.10498, -0.1586
0.106293, -0.158875
0.10498, -0.1586

 

Edited by Joey P

Share this post


Link to post
Share on other sites
  • 0

Good question Yevheniy,

Reading Data from a QVRT file involves knowledge of the QVRT packet structure and requires NDA.  However under NDA, the procedure is quite simple.

1.  Open a .QVRT file for reading

2.  Use packet headers to identify data packets

3.  Access Raw IQ data from data packets.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×