From ffcfa66f021d2265d89013c2a246198d94c9bfd1 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Tue, 10 Oct 2023 16:28:25 +0200
Subject: [PATCH] Searches for run_measurement error

---
 ohmpi/hardware_components/mb_2023_0_X.py | 4 +---
 ohmpi/hardware_components/mb_2024_0_2.py | 7 +++++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py
index ab23d29c..48849b9c 100644
--- a/ohmpi/hardware_components/mb_2023_0_X.py
+++ b/ohmpi/hardware_components/mb_2023_0_X.py
@@ -247,9 +247,7 @@ class Rx(RxAbstract):
 
     def _adc_gain_auto(self):
         self.exec_logger.event(f'{self.board_name}\trx_adc_auto_gain\tbegin\t{datetime.datetime.utcnow()}')
-        gain_0 = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P0))
-        gain_2 = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P2))
-        gain = np.min([gain_0, gain_2])
+        gain = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P0, ads.P1))
         self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
         self.gain = gain
         self.exec_logger.event(f'{self.board_name}\trx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}')
diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py
index f318c54d..9bb65d72 100644
--- a/ohmpi/hardware_components/mb_2024_0_2.py
+++ b/ohmpi/hardware_components/mb_2024_0_2.py
@@ -105,6 +105,13 @@ class Rx(Rx_mb_2023):
         # TODO: try to only log this event and not the one created by super()
         self.exec_logger.event(f'{self.board_name}\trx_init\tend\t{datetime.datetime.utcnow()}')
 
+    def _adc_gain_auto(self):
+        self.exec_logger.event(f'{self.board_name}\trx_adc_auto_gain\tbegin\t{datetime.datetime.utcnow()}')
+        gain = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P0))
+        self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
+        self.gain = gain
+        self.exec_logger.event(f'{self.board_name}\trx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}')
+
     def _dg411_gain_auto(self):
         if self.voltage < self._vmn_hardware_offset :
             self._dg411_gain = 1.
-- 
GitLab