Skip to content

SFF-8472 Rx power conversion function incorrect #449

@JaapKeuter

Description

@JaapKeuter

# RX_PWR(uW) = RX_PWR_4 * RX_PWR_AD +
# RX_PWR_3 * RX_PWR_AD +
# RX_PWR_2 * RX_PWR_AD +
# RX_PWR_1 * RX_PWR_AD +
# RX_PWR(0)
off = self.dom_ext_calibration_constants['RX_PWR_4']['offset']
rx_pwr_byte3 = int(eeprom_data[off], 16)
rx_pwr_byte2 = int(eeprom_data[off + 1], 16)
rx_pwr_byte1 = int(eeprom_data[off + 2], 16)
rx_pwr_byte0 = int(eeprom_data[off + 3], 16)
rx_pwr_4 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff)
off = self.dom_ext_calibration_constants['RX_PWR_3']['offset']
rx_pwr_byte3 = int(eeprom_data[off], 16)
rx_pwr_byte2 = int(eeprom_data[off + 1], 16)
rx_pwr_byte1 = int(eeprom_data[off + 2], 16)
rx_pwr_byte0 = int(eeprom_data[off + 3], 16)
rx_pwr_3 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff)
off = self.dom_ext_calibration_constants['RX_PWR_2']['offset']
rx_pwr_byte3 = int(eeprom_data[off], 16)
rx_pwr_byte2 = int(eeprom_data[off + 1], 16)
rx_pwr_byte1 = int(eeprom_data[off + 2], 16)
rx_pwr_byte0 = int(eeprom_data[off + 3], 16)
rx_pwr_2 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff)
off = self.dom_ext_calibration_constants['RX_PWR_1']['offset']
rx_pwr_byte3 = int(eeprom_data[off], 16)
rx_pwr_byte2 = int(eeprom_data[off + 1], 16)
rx_pwr_byte1 = int(eeprom_data[off + 2], 16)
rx_pwr_byte0 = int(eeprom_data[off + 3], 16)
rx_pwr_1 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff)
off = self.dom_ext_calibration_constants['RX_PWR_0']['offset']
rx_pwr_byte3 = int(eeprom_data[off], 16)
rx_pwr_byte2 = int(eeprom_data[off + 1], 16)
rx_pwr_byte1 = int(eeprom_data[off + 2], 16)
rx_pwr_byte0 = int(eeprom_data[off + 3], 16)
rx_pwr_0 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff)
rx_pwr = (rx_pwr_4 * result) + (rx_pwr_3 * result) + (rx_pwr_2 * result) + (rx_pwr_1 * result) + rx_pwr_0

SFF-8472 section 9.3

The specification states, under 5)
Received power, RX_PWR, is given in uW by the following equation:

Rx_PWR (uW) = Rx_PWR(4) * Rx_PWR_ADe4 (16 bit unsigned integer) +
           Rx_PWR(3) * Rx_PWR_ADe3 (16 bit unsigned integer) +
           Rx_PWR(2) * Rx_PWR_ADe2 (16 bit unsigned integer) +
           Rx_PWR(1) * Rx_PWR_AD (16 bit unsigned integer) +
           Rx_PWR(0)

which means Rx_PWR_AD is raised to the power of 4, 3 and 2 respectively in the expression. The comment and code does not reflect that.

Furthermore, the calibration constants are stored in IEEE Std 754 single precision float format in the device. These cannot be treated as integers, as is done in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions