|
7 | 7 | from __future__ import print_function |
8 | 8 |
|
9 | 9 | try: |
10 | | - import fcntl |
11 | 10 | import struct |
12 | | - import sys |
13 | | - import time |
14 | | - import os |
15 | | - import getopt |
16 | | - import types |
17 | | - from math import log10 |
18 | 11 | from .sff8024 import type_of_transceiver # Dot module supports both Python 2 and Python 3 using explicit relative import methods |
19 | 12 | from .sff8024 import type_abbrv_name # Dot module supports both Python 2 and Python 3 using explicit relative import methods |
20 | 13 | from .sffbase import sffbase # Dot module supports both Python 2 and Python 3 using explicit relative import methods |
@@ -828,49 +821,23 @@ def calc_rx_power(self, eeprom_data, offset, size): |
828 | 821 |
|
829 | 822 | # External Calibration |
830 | 823 |
|
831 | | - # RX_PWR(uW) = RX_PWR_4 * RX_PWR_AD + |
832 | | - # RX_PWR_3 * RX_PWR_AD + |
833 | | - # RX_PWR_2 * RX_PWR_AD + |
834 | | - # RX_PWR_1 * RX_PWR_AD + |
835 | | - # RX_PWR(0) |
836 | | - off = self.dom_ext_calibration_constants['RX_PWR_4']['offset'] |
837 | | - rx_pwr_byte3 = int(eeprom_data[off], 16) |
838 | | - rx_pwr_byte2 = int(eeprom_data[off + 1], 16) |
839 | | - rx_pwr_byte1 = int(eeprom_data[off + 2], 16) |
840 | | - rx_pwr_byte0 = int(eeprom_data[off + 3], 16) |
841 | | - rx_pwr_4 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff) |
842 | | - |
843 | | - off = self.dom_ext_calibration_constants['RX_PWR_3']['offset'] |
844 | | - rx_pwr_byte3 = int(eeprom_data[off], 16) |
845 | | - rx_pwr_byte2 = int(eeprom_data[off + 1], 16) |
846 | | - rx_pwr_byte1 = int(eeprom_data[off + 2], 16) |
847 | | - rx_pwr_byte0 = int(eeprom_data[off + 3], 16) |
848 | | - rx_pwr_3 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff) |
849 | | - |
850 | | - off = self.dom_ext_calibration_constants['RX_PWR_2']['offset'] |
851 | | - rx_pwr_byte3 = int(eeprom_data[off], 16) |
852 | | - rx_pwr_byte2 = int(eeprom_data[off + 1], 16) |
853 | | - rx_pwr_byte1 = int(eeprom_data[off + 2], 16) |
854 | | - rx_pwr_byte0 = int(eeprom_data[off + 3], 16) |
855 | | - rx_pwr_2 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff) |
856 | | - |
857 | | - off = self.dom_ext_calibration_constants['RX_PWR_1']['offset'] |
858 | | - rx_pwr_byte3 = int(eeprom_data[off], 16) |
859 | | - rx_pwr_byte2 = int(eeprom_data[off + 1], 16) |
860 | | - rx_pwr_byte1 = int(eeprom_data[off + 2], 16) |
861 | | - rx_pwr_byte0 = int(eeprom_data[off + 3], 16) |
862 | | - rx_pwr_1 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff) |
863 | | - |
864 | | - off = self.dom_ext_calibration_constants['RX_PWR_0']['offset'] |
865 | | - rx_pwr_byte3 = int(eeprom_data[off], 16) |
866 | | - rx_pwr_byte2 = int(eeprom_data[off + 1], 16) |
867 | | - rx_pwr_byte1 = int(eeprom_data[off + 2], 16) |
868 | | - rx_pwr_byte0 = int(eeprom_data[off + 3], 16) |
869 | | - rx_pwr_0 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff) |
870 | | - |
871 | | - rx_pwr = (rx_pwr_4 * result) + (rx_pwr_3 * result) + (rx_pwr_2 * result) + (rx_pwr_1 * result) + rx_pwr_0 |
872 | | - |
873 | | - result = float(result * 0.0001) |
| 824 | + # SFF-8472 Rev 12.4 section 9.3 5) |
| 825 | + # Rx_PWR (uW) = Rx_PWR(4) * Rx_PWR_ADe4 (16 bit unsigned integer) + |
| 826 | + # Rx_PWR(3) * Rx_PWR_ADe3 (16 bit unsigned integer) + |
| 827 | + # Rx_PWR(2) * Rx_PWR_ADe2 (16 bit unsigned integer) + |
| 828 | + # Rx_PWR(1) * Rx_PWR_AD (16 bit unsigned integer) + |
| 829 | + # Rx_PWR(0) |
| 830 | + rx_pwr_ad = result |
| 831 | + result = 0 |
| 832 | + for i in range(0, 5): |
| 833 | + field_name = f'RX_PWR_{i}' |
| 834 | + rx_pwr = self.dom_ext_calibration_constants[field_name] |
| 835 | + off = rx_pwr['offset'] |
| 836 | + size = rx_pwr['size'] |
| 837 | + coeff = self.float_from_bytes(eeprom_data[off:off+size]) |
| 838 | + result += coeff * rx_pwr_ad ** i |
| 839 | + |
| 840 | + result = result * 0.0001 # uW to mW |
874 | 841 | #print(indent, name, " : ", power_in_dbm_str(result)) |
875 | 842 | retval = self.power_in_dbm_str(result) |
876 | 843 | else: |
|
0 commit comments