Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential read errors for bladerf_get_correction #997

Open
QuantumEF opened this issue Jan 5, 2025 · 0 comments
Open

Potential read errors for bladerf_get_correction #997

QuantumEF opened this issue Jan 5, 2025 · 0 comments

Comments

@QuantumEF
Copy link

QuantumEF commented Jan 5, 2025

BladeRf Version Info

BladeRf x40

 bladeRF-cli version:        1.9.0-git-fe3304d7
  libbladeRF version:         2.5.1-git-fe3304d7

  Firmware version:           2.4.0-git-a3d5c55f
  FPGA version:               0.14.0 (configured from SPI flash)

after setting BLADERF_CORR_DCOFF_I or BLADERF_CORR_DCOFF_Q to 0, reads from bladerf_get_correction output a value of 2048.

Further, setting values 0-15 inclusive also report 2048 while values 16-32 set it to 2064.
This pattern seems to repeat.

C Test Script
#include <libbladeRF.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const bladerf_channel CHANNEL = BLADERF_CHANNEL_TX(0);
int main(int argc, char *argv[]) {
  printf("Hello, World!\n");

  struct bladerf *dev = NULL;
  struct bladerf_devinfo dev_info;

  /* Initialize the information used to identify the desired device
   * to all wildcard (i.e., "any device") values */
  bladerf_init_devinfo(&dev_info);

  /* Request a device with the provided serial number.
   * Invalid strings should simply fail to match a device. */
  if (argc >= 2) {
    strncpy(dev_info.serial, argv[1], sizeof(dev_info.serial) - 1);
  }

  int status = bladerf_open_with_devinfo(&dev, &dev_info);
  if (status != 0) {
    fprintf(stderr, "Unable to open device: %s\n", bladerf_strerror(status));
    return 1;
  }

  // gets 2048 for inclusive values 0-15 and 2064 for 16-31, etc
  short int corr_i = 0;
  short int corr_q = 32;

  short int corr_phase = 0;
  short int corr_gain = 0;

  int res = 0;

  //

  res = bladerf_set_correction(dev, CHANNEL, BLADERF_CORR_DCOFF_I, corr_i);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  res = bladerf_get_correction(dev, CHANNEL, BLADERF_CORR_DCOFF_I, &corr_i);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  //

  res = bladerf_set_correction(dev, CHANNEL, BLADERF_CORR_DCOFF_Q, corr_q);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  res = bladerf_get_correction(dev, CHANNEL, BLADERF_CORR_DCOFF_Q, &corr_q);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  //

  res = bladerf_set_correction(dev, CHANNEL, BLADERF_CORR_PHASE, corr_phase);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  res = bladerf_get_correction(dev, CHANNEL, BLADERF_CORR_PHASE, &corr_phase);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  //

  res = bladerf_set_correction(dev, CHANNEL, BLADERF_CORR_GAIN, corr_gain);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  res = bladerf_get_correction(dev, CHANNEL, BLADERF_CORR_GAIN, &corr_gain);

  if (res != 0) {
    printf("Error: %d\n", res);
    return 1;
  }

  //

  printf("I: %d, Q: %d, Phase: %d, Gain: %d\n", corr_i, corr_q, corr_phase,
         corr_gain);

  return 0;
}

I originally noticed this with other program I am working on here.

Potentially, but probably unrelated (from a long time ago) issue: #284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant