Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Think I fixed brf2.c gives ~3Gb/s of entropy at ~30% fail after von n…
Browse files Browse the repository at this point in the history
…eumann debiasing. Next I'll fold the changes in to brf_entropy and do a release!
  • Loading branch information
pwarren committed Jan 20, 2014
1 parent 05f04cf commit 7c1bf6d
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/brf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ static void *rx_stream_callback(struct bladerf *dev,
int buffercounter = 0;
int16_t *sample = (int16_t *)samples;
int ch, ch2;
int bufsize = 5500;
int bufsize = num_samples/2;
int out_block_size = 2048;

bitbuffer = malloc(bufsize * sizeof(int16_t));
memset(bitbuffer,0,bufsize);

buffercounter = 0;
bitcounter = 0;

for(i=0; i<num_samples*2; i++) {
for(i=0; i<num_samples * 2; i++) {
for (j=0; j < 10; j+= 2) {
ch = (*sample >> j) & 0x01;
ch2 = (*sample >> (j+1)) & 0x01;
Expand All @@ -61,27 +62,36 @@ static void *rx_stream_callback(struct bladerf *dev,
bitcounter = 0;
}


if (buffercounter % out_block_size == 0) {
fwrite(&bitbuffer[buffercounter - out_block_size],
sizeof(int16_t),
out_block_size,
stdout);
}

/* Not threaadsafe!
* if you set bufsize too high, the next callback might
* happen before you get here to write anything to output!
* time for locking, and discarding packets!
*/
*/
if (buffercounter >= bufsize) {
fwrite(bitbuffer,
sizeof(int16_t),
buffercounter,
stdout);
buffercounter = 0;
bitcounter = 0;
memset(bitbuffer,0,bufsize);
}
}
sample ++;
}

free(bitbuffer);

/* Works well printing here at buffer size ~40MB/s
/* fwrite(bitbuffer, */
/* sizeof(int16_t), */
/* buffercounter, */
/* stdout); */

free(bitbuffer);
if (!do_exit) {
return samples;
} else {
Expand Down Expand Up @@ -151,12 +161,14 @@ int main(int argc, char * argv) {
log_line(LOG_DEBUG, "Sample rate set to %d", actual_value);

/* Set the filter bandwidth to the same as the sample rate for now */
r = bladerf_set_bandwidth(device, BLADERF_MODULE_RX, samp_rate, &actual_value);
/*r = bladerf_set_bandwidth(device, BLADERF_MODULE_RX, samp_rate, &actual_value);
if (r < 0) {
log_line(LOG_DEBUG,"Failed to set sample rate: %s", bladerf_strerror(r));
exit(EXIT_FAILURE);
}
log_line(LOG_DEBUG, "Bandwidth rate set to %d", actual_value);
log_line(LOG_DEBUG, "Bandwidth rate set to %d", actual_value); */

r = bladerf_set_lpf_mode(device, BLADERF_MODULE_RX, BLADERF_LPF_BYPASSED);

log_line(LOG_DEBUG, "Setting Frequency to %d", frequency);

Expand Down

0 comments on commit 7c1bf6d

Please sign in to comment.