diff --git a/NPM/get_data_modbus_v3.py b/NPM/get_data_modbus_v3.py index 120688a..9ee846d 100755 --- a/NPM/get_data_modbus_v3.py +++ b/NPM/get_data_modbus_v3.py @@ -113,7 +113,8 @@ try: # Validate response length if len(byte_data) < response_length: - print(f"[ERROR] Incomplete response received: {byte_data.hex()}") + if not dry_run: + print(f"[ERROR] Incomplete response received: {byte_data.hex()}") raise Exception("Incomplete response") # Verify CRC @@ -121,7 +122,8 @@ try: calculated_crc = crc16(byte_data[:-2]) if received_crc != calculated_crc: - print("[ERROR] CRC check failed! Corrupted data received.") + if not dry_run: + print("[ERROR] CRC check failed! Corrupted data received.") raise Exception("CRC check failed") # Convert response to hex for debugging @@ -197,16 +199,20 @@ try: status_calc_crc = crc16(status_response[:-2]) if status_recv_crc == status_calc_crc: npm_status = int.from_bytes(status_response[3:5], byteorder='big') & 0xFF - print(f"NPM status: 0x{npm_status:02X} ({npm_status})") + if not dry_run: + print(f"NPM status: 0x{npm_status:02X} ({npm_status})") else: - print("[WARNING] NPM status CRC check failed, keeping default") + if not dry_run: + print("[WARNING] NPM status CRC check failed, keeping default") else: - print(f"[WARNING] NPM status incomplete response ({len(status_response)} bytes)") + if not dry_run: + print(f"[WARNING] NPM status incomplete response ({len(status_response)} bytes)") ser.close() except Exception as e: - print(f"[ERROR] Sensor communication failed: {e}") + if not dry_run: + print(f"[ERROR] Sensor communication failed: {e}") # Variables already set to -1 at the beginning finally: