update message

This commit is contained in:
2026-02-11 23:03:59 +01:00
parent fbae73828f
commit 8ee934cb70
3 changed files with 42 additions and 18 deletions

View File

@@ -176,7 +176,7 @@ int scd30_read_data(scd30_handle_t *handle, scd30_data_t *data) {
} }
// 2. Wait for Slave to consult Python // 2. Wait for Slave to consult Python
vTaskDelay(pdMS_TO_TICKS(50)); // Give ample time for UART bridge vTaskDelay(pdMS_TO_TICKS(100)); // Give ample time for UART bridge
// 3. Read Data // 3. Read Data
cmd = i2c_cmd_link_create(); cmd = i2c_cmd_link_create();

View File

@@ -1,6 +1,6 @@
Timestamp,Simulated_CO2,Target_Received_Msg,Status Timestamp,Simulated_CO2,Target_Received_Msg,Status
19:43:59,400.0,"W (4783) SCD30: Command Write Failed, retrying... (0)",CHECK 23:02:18,400.0,"CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
19:43:59,850.5,"W (4883) SCD30: CRC failed or Read error, retrying... (1)",CHECK 23:02:21,850.5,"CO2: 850.50 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
19:44:02,1200.0,"CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",CHECK 23:02:23,1200.0,"CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
19:44:03,2500.0,"W (8393) SCD30: CRC failed or Read error, retrying... (0)",CHECK 23:02:25,2500.0,"CO2: 2500.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
19:44:06,5000.0,"CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",CHECK 23:02:27,5000.0,"CO2: 5000.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
1 Timestamp Simulated_CO2 Target_Received_Msg Status
2 19:43:59 23:02:18 400.0 W (4783) SCD30: Command Write Failed, retrying... (0) CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CHECK PASS
3 19:43:59 23:02:21 850.5 W (4883) SCD30: CRC failed or Read error, retrying... (1) CO2: 850.50 ppm, Temp: 24.00 °C, Humidity: 50.00 % CHECK PASS
4 19:44:02 23:02:23 1200.0 CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CHECK PASS
5 19:44:03 23:02:25 2500.0 W (8393) SCD30: CRC failed or Read error, retrying... (0) CO2: 2500.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CHECK PASS
6 19:44:06 23:02:27 5000.0 CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CO2: 5000.00 ppm, Temp: 24.00 °C, Humidity: 50.00 % CHECK PASS

View File

@@ -3,7 +3,7 @@ import time
from hil_lib import SCD30_HIL_Lib from hil_lib import SCD30_HIL_Lib
# Device paths from your environment # Device paths from your environment
Device = 'HIL' Device = 'PC'
if Device == 'PC': if Device == 'PC':
EMULATOR = 'COM11'#'/dev/i2c_emulator' EMULATOR = 'COM11'#'/dev/i2c_emulator'
@@ -30,23 +30,47 @@ with open(LOG_FILE, mode='w', newline='') as f:
for co2 in test_points: for co2 in test_points:
print(f"\n[PHASE] Setting Simulated CO2 to {co2} ppm") print(f"\n[PHASE] Setting Simulated CO2 to {co2} ppm")
# 1. Feed the bridge until the Target performs a successful Read # Flush buffers to ensure we don't read old data
# We loop briefly to wait for the Target's polling interval hil.emulator.reset_input_buffer()
hil.target.reset_input_buffer()
# 1. Feed the bridge AND listen for Target output simultaneously
# The Master might retry multiple times, so we must keep the bridge alive
# until we see a final result from the Target.
timeout = time.time() + 10 timeout = time.time() + 10
data_served = False data_served = False
target_msg = ""
while time.time() < timeout: while time.time() < timeout:
# Service the Bridge
if hil.process_bridge(co2, 24.0, 50.0): if hil.process_bridge(co2, 24.0, 50.0):
data_served = True data_served = True
break
#time.sleep(4)
if not data_served:
print("Error: Target didn't request data within 10s.")
continue
# 2. Capture what the Target actually saw # Check for Target Output
# Wait for Target to print the result to Serial if hil.target.in_waiting:
time.sleep(0.5) line = hil.get_target_reading()
target_msg = hil.get_target_reading() if line:
# We are looking for either a successful reading or a final failure message
# Success example: "CO2: 400.00 ppm..."
# Warning example: "W (123) SCD30: CRC failed..." (We might want to keep going if it's just a warning)
# Error example: "E (123) SCD30: ..."
# Ideally, we wait for the formatted output
if "CO2:" in line or "Read data failed" in line:
target_msg = line
break
else:
# It might be a warning retry log, let's capture it but keep going
# If we overwrite target_msg, we might miss the final success
# But for debugging, let's print it
print(f"[LOG] {line}")
if not target_msg:
if not data_served:
print("Error: Target didn't request data within 10s.")
else:
print("Error: Target requested data but yielded no final result.")
continue
# 3. Simple Validation # 3. Simple Validation
status = "PASS" if str(int(co2)) in target_msg else "CHECK" status = "PASS" if str(int(co2)) in target_msg else "CHECK"