SDRPLAY linux commandline tools?

Add useful snippets of code or links to entire SDR projects.
Sasan
Posts: 98
Joined: Sat Jun 27, 2015 1:15 am

Re: SDRPLAY linux commandline tools?

Postby Sasan » Tue Mar 15, 2016 10:29 am

I know this is a Linux thread, but maybe my comments help someone:
I tried to compile and use this sample code on Mac OS X 10.11.3 (latest version)
At first, I was getting this error like other users:
Writing samples...
Short read, samples lost, exiting!

Library error 0, exiting...


Then, I removed this section:

Code: Select all

 if ((uint32_t)n_read < out_block_size) {
            fprintf(stderr, "Short read, samples lost, exiting!\n");
            break;
        }
       

(According to this post by user 0815: viewtopic.php?f=9&t=541&start=10#p2265 )
Now the code works as expected (I've tested both 8 and 16-bit data samples)
I recorded some samples to a file. Converted it to 8-bit signed integer with this command:
sox -t raw -r 250000 -b 8 -c 1 -e unsigned-integer sdrplay_iq.raw -t raw -r 250000 -c 1 -e signed-integer sdrplay_converted.raw
Then I converted this file to a Gqrx compatible format, using this code:
https://gist.github.com/DrPaulBrewer/91 ... a51f7febb5

Now I can listen to the recorded FM station on Gqrx.
Note: I've set the sample rate to 1.536 Msps.
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

0815
Posts: 45
Joined: Sat Jan 30, 2016 3:07 pm

Re: SDRPLAY linux commandline tools?

Postby 0815 » Tue Mar 15, 2016 12:49 pm

i am not sure about the 16bit output if it is valid,when i play it it sounds too fast....... like played double speed....

i changed:

Code: Select all

for (i=0; i < samplesPerPacket; i++)
        {
            buffer[j++] = ibuf[i];
            buffer[j++] = qbuf[i];
        }   


and

Code: Select all

short *buffer;


and

Code: Select all

buffer = malloc(DEFAULT_BUF_LENGTH  * sizeof(short));


is the output 16 bit signed or unsigned? miri tells 16bit left justified integers...?

maybe somebody can test the 16 bit either....
Last edited by 0815 on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Bill_C
Posts: 3
Joined: Tue Mar 15, 2016 1:38 am

Re: SDRPLAY linux commandline tools?

Postby Bill_C » Wed Mar 16, 2016 11:16 am

Hi 0815,

Your updated version of rawIQ.c this seems to work fine on my Ubuntu system for continuous data storage to file! This code doesn't include a parameter allowing the bandwidth to be set, but it looks like that should be easy to include in the mir_sdr_Init routine.

Many thanks, Bill
Last edited by Bill_C on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Sasan
Posts: 98
Joined: Sat Jun 27, 2015 1:15 am

Re: SDRPLAY linux commandline tools?

Postby Sasan » Wed Mar 16, 2016 4:03 pm

Dear SDRPlay Team
Can you please help regarding the 8 vs 16-bit issue?
What is lost when we use your sample code (which truncates I/Q samples to 8-bits)?
I tried to convert 16-bit stored samples to another format (Gqrx or SDRSharp) but haven't succeeded so far.
Even a simple hint would be appreciated.

Thanks
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

sdrplay
Posts: 626
Joined: Wed Jan 07, 2015 7:58 am

Re: SDRPLAY linux commandline tools?

Postby sdrplay » Wed Mar 16, 2016 4:58 pm

The output of the RSP is 16 bits. To be compatible with the RTL code you need to remove the top 8 bits which is what...

>> 8

is doing

In the ADS-B code we have to do >> 8 + 127

so you can try with that as well.

Hope that helps,

Best regards,

SDRplay Support
Last edited by sdrplay on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Sasan
Posts: 98
Joined: Sat Jun 27, 2015 1:15 am

Re: SDRPLAY linux commandline tools?

Postby Sasan » Wed Mar 16, 2016 6:14 pm

sdrplay wrote:The output of the RSP is 16 bits. To be compatible with the RTL code you need to remove the top 8 bits which is what...

>> 8

is doing

In the ADS-B code we have to do >> 8 + 127

so you can try with that as well.

Hope that helps,

Best regards,

SDRplay Support


I'm puzzled. If we remove the top 8 bits and then add a constant value (127) to it, we're always losing some data (the upper half which is truncated and later replaced by 127)
What I meant was: how to use the original 16-bit I/Q samples (RTL-SDR and HackRF use 8-bit samples, but higher level SDRs like USRP and BladeRF use 16-bit samples. I'm trying to use all the 16-bit data, like those high-end SDRs)

Thanks
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

sdrplay
Posts: 626
Joined: Wed Jan 07, 2015 7:58 am

Re: SDRPLAY linux commandline tools?

Postby sdrplay » Wed Mar 16, 2016 6:49 pm

If you want a 16 bit output, don't do the right shift and change the output buffer to 16 bits instead of 8

Best regards,

SDRplay
Last edited by sdrplay on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Sasan
Posts: 98
Joined: Sat Jun 27, 2015 1:15 am

Re: SDRPLAY linux commandline tools?

Postby Sasan » Wed Mar 16, 2016 7:54 pm

0815 wrote:i am not sure about the 16bit output if it is valid,when i play it it sounds too fast....... like played double speed....


I have the same problem.
(I've changed the original source code to write 16-bit samples to file. Then converted the raw IQ file with sox, to change from unsigned-integer type to signed-integer. Then, using the modified rtl2gqrx utility, converted it to Gqrx compatible format. Gqrx can play it, but it's like double speed)
My source code is attached)
Attachments
Archive.zip
(4.38 KiB) Downloaded 182 times
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

sdrplay
Posts: 626
Joined: Wed Jan 07, 2015 7:58 am

Re: SDRPLAY linux commandline tools?

Postby sdrplay » Wed Mar 16, 2016 8:22 pm

I'm not sure about the post processing - what is the -r option in sox doing? The sample rate used in the play_sdr is 2MHz - are you taking that into account anywhere?

Best regards,

SDRplay Support
Last edited by sdrplay on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

0815
Posts: 45
Joined: Sat Jan 30, 2016 3:07 pm

Re: SDRPLAY linux commandline tools?

Postby 0815 » Wed Mar 16, 2016 8:31 pm

-r, --rate RATE[k]
Gives the sample rate in Hz

i used the sample rate for it that i used when recording with rawIQ
Last edited by 0815 on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason


Return to “Code Corner”

Who is online

Users browsing this forum: No registered users and 1 guest