diff --git a/hm_pyhelper/hardware_definitions.py b/hm_pyhelper/hardware_definitions.py index bede6ea..cab3137 100644 --- a/hm_pyhelper/hardware_definitions.py +++ b/hm_pyhelper/hardware_definitions.py @@ -26,7 +26,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi3-64'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 38, 'MAC': 'eth0', @@ -48,7 +47,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi3-64'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 38, 'MAC': 'eth0', @@ -65,14 +63,13 @@ def is_raspberry_pi() -> bool: }, # Nebra Outdoor Hotspot Gen2 - # Note:: assuming outdoor2 is equivalent to light miner 2 + # Note:: assuming outdoor2 is equivalent to indoor2 'nebra-outdoor2': { 'FRIENDLY': 'Nebra ROCK Pi 4 Outdoor', 'SUPPORTED_MODELS': ['Nebra ROCK Pi 4 Outdoor'], 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['rockpi-4b-rk3399'], 'SPIBUS': 'spidev32766.0', - 'KEY_STORAGE_BUS': '/dev/i2c-7', 'SWARM_KEY_URI': 'ecc://i2c-7:96?slot=0', 'RESET': 149, 'MAC': 'eth0', @@ -98,7 +95,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv6hf', 'BALENA_DEVICE_TYPE': ['raspberry-pi'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 22, 'MAC': 'wlan0', @@ -120,7 +116,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv6hf', 'BALENA_DEVICE_TYPE': ['raspberry-pi'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 22, 'MAC': 'wlan0', @@ -142,7 +137,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['radxa-zero'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-3', 'SWARM_KEY_URI': 'ecc://i2c-3:96?slot=0', 'RESET': 415, 'MAC': 'wlan0', @@ -164,7 +158,7 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv6hf', 'BALENA_DEVICE_TYPE': ['raspberry-pi'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', + 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 4, 'MAC': 'wlan0', 'STATUS': 26, @@ -185,7 +179,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv7hf', 'BALENA_DEVICE_TYPE': ['beaglebone-black'], 'SPIBUS': 'spidev1.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 60, 'MAC': 'eth0', @@ -207,7 +200,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv7hf', 'BALENA_DEVICE_TYPE': ['beaglebone-pocket'], 'SPIBUS': 'spidev1.2', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 60, 'MAC': 'wlan0', @@ -229,7 +221,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['rockpi-4b-rk3399'], 'SPIBUS': 'spidev32766.0', - 'KEY_STORAGE_BUS': '/dev/i2c-7', 'SWARM_KEY_URI': 'ecc://i2c-7:96?slot=0', 'RESET': 149, 'MAC': 'eth0', @@ -253,7 +244,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'armv7hf', 'BALENA_DEVICE_TYPE': ['asus-tinker-board'], 'SPIBUS': 'spidev2.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 167, 'MAC': 'eth0', @@ -275,7 +265,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 25, 'MAC': 'wlan0', @@ -297,7 +286,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi3-64', 'raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 25, 'MAC': 'wlan0', @@ -319,7 +307,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'wlan0', @@ -341,7 +328,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 23, 'MAC': 'wlan0', @@ -363,7 +349,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'wlan0', @@ -390,7 +375,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-0', 'SWARM_KEY_URI': 'ecc://i2c-0:96?slot=0', 'RESET': 23, 'MAC': 'eth0', @@ -412,7 +396,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 4, 'MAC': 'wlan0', @@ -441,7 +424,6 @@ def is_raspberry_pi() -> bool: 'raspberrypi0-2w-64', 'raspberrypi3-64', 'raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 22, 'MAC': 'eth0', @@ -465,7 +447,6 @@ def is_raspberry_pi() -> bool: 'raspberrypi0-2w-64', 'raspberrypi3-64', 'raspberrypi4-64'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'eth0', @@ -487,7 +468,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypicm4-ioboard'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'wlan0', @@ -509,7 +489,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypicm4-ioboard'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-10', 'SWARM_KEY_URI': 'ecc://i2c-10:96?slot=0', 'RESET': 23, 'MAC': 'wlan0', @@ -531,7 +510,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypicm4-ioboard'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'wlan0', @@ -553,7 +531,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypi4-64'], 'SPIBUS': 'spidev0.0', # There is a CSN1 pin which is connected to GPIO6 (HAT Pin 31) - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 22, 'MAC': 'eth0', @@ -575,7 +552,6 @@ def is_raspberry_pi() -> bool: 'CPU_ARCH': 'arm64', 'BALENA_DEVICE_TYPE': ['raspberrypicm4-ioboard'], 'SPIBUS': 'spidev0.0', - 'KEY_STORAGE_BUS': '/dev/i2c-1', 'SWARM_KEY_URI': 'ecc://i2c-1:96?slot=0', 'RESET': 17, 'MAC': 'wlan0', diff --git a/hm_pyhelper/miner_param.py b/hm_pyhelper/miner_param.py index ce75104..aab1928 100644 --- a/hm_pyhelper/miner_param.py +++ b/hm_pyhelper/miner_param.py @@ -115,28 +115,19 @@ def get_gateway_mfr_command(sub_command: str, slot: int = 0) -> list: command = [gateway_mfr_path] gateway_mfr_version = get_gateway_mfr_version() - if Version('0.1.1') < gateway_mfr_version < Version('0.2.0'): - try: - device_arg = [ - '--path', - get_variant_attribute(os.getenv('VARIANT'), 'KEY_STORAGE_BUS') - ] - command.extend(device_arg) - except (UnknownVariantException, UnknownVariantAttributeException) as e: - LOGGER.warning(str(e) + ' Omitting --path arg.') - - command.append(sub_command) - - # In case of "key" command, append the slot number 0 at the end. - if sub_command == "key": - command.append("0") - elif gateway_mfr_version >= Version('0.2.0'): + if gateway_mfr_version >= Version('0.2.0'): try: - device_arg = [ - '--device', - get_variant_attribute(os.getenv('VARIANT'), 'SWARM_KEY_URI') - ] + if os.getenv('SWARM_KEY_URI'): + device_arg = [ + '--device', + os.getenv('SWARM_KEY_URI') + ] + else: + device_arg = [ + '--device', + get_variant_attribute(os.getenv('VARIANT'), 'SWARM_KEY_URI') + ] command.extend(device_arg) except (UnknownVariantException, UnknownVariantAttributeException) as e: LOGGER.warning(str(e) + ' Omitting --device arg.') diff --git a/hm_pyhelper/tests/test_miner_param.py b/hm_pyhelper/tests/test_miner_param.py index a4e8d78..f565fe1 100644 --- a/hm_pyhelper/tests/test_miner_param.py +++ b/hm_pyhelper/tests/test_miner_param.py @@ -119,44 +119,6 @@ def test_get_gateway_mfr_version_v021(self, mocked_subprocess_run): mocked_subprocess_run.assert_called_once_with( [ANY, '--version'], capture_output=True, check=True) - @patch('hm_pyhelper.miner_param.get_gateway_mfr_version', - return_value=Version('0.1.7')) - def test_get_gateway_mfr_command_v017(self, mocked_get_gateway_mfr_version): - actual_result = get_gateway_mfr_command('key') - expected_result = [ANY, '--path', '/dev/i2c-X', 'key', '0'] - self.assertListEqual(actual_result, expected_result) - mocked_get_gateway_mfr_version.assert_called_once() - - actual_result = get_gateway_mfr_command('info') - expected_result = [ANY, '--path', '/dev/i2c-X', 'info'] - self.assertListEqual(actual_result, expected_result) - - @patch.dict('os.environ', {"VARIANT": "NEBHNT-INVALID"}) - @patch('hm_pyhelper.miner_param.get_gateway_mfr_version', - return_value=Version('0.1.7')) - def test_get_gateway_mfr_command_v017_no_variant(self, mocked_get_gateway_mfr_version): - actual_result = get_gateway_mfr_command('key') - expected_result = [ANY, 'key', '0'] - self.assertListEqual(actual_result, expected_result) - mocked_get_gateway_mfr_version.assert_called_once() - - actual_result = get_gateway_mfr_command('info') - expected_result = [ANY, 'info'] - self.assertListEqual(actual_result, expected_result) - - @patch.dict('os.environ', {"VARIANT": "NEBHNT-NO-ECC-ADDRESS"}) - @patch('hm_pyhelper.miner_param.get_gateway_mfr_version', - return_value=Version('0.1.7')) - def test_get_gateway_mfr_command_v017_no_KEY_STORAGE_BUS(self, mocked_get_gateway_mfr_version): - actual_result = get_gateway_mfr_command('key') - expected_result = [ANY, 'key', '0'] - self.assertListEqual(actual_result, expected_result) - mocked_get_gateway_mfr_version.assert_called_once() - - actual_result = get_gateway_mfr_command('info') - expected_result = [ANY, 'info'] - self.assertListEqual(actual_result, expected_result) - @patch('hm_pyhelper.miner_param.get_gateway_mfr_version', return_value=Version('0.2.1')) def test_get_gateway_mfr_command_v021(self, mocked_get_gateway_mfr_version): diff --git a/setup.py b/setup.py index faabd23..f4f2112 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='hm_pyhelper', - version='0.13.54', + version='0.13.55', author="Nebra Ltd", author_email="support@nebra.com", description="Helium Python Helper",