update message
This commit is contained in:
@@ -176,7 +176,7 @@ int scd30_read_data(scd30_handle_t *handle, scd30_data_t *data) {
|
||||
}
|
||||
|
||||
// 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
|
||||
cmd = i2c_cmd_link_create();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Timestamp,Simulated_CO2,Target_Received_Msg,Status
|
||||
19:43:59,400.0,"W (4783) SCD30: Command Write Failed, retrying... (0)",CHECK
|
||||
19:43:59,850.5,"W (4883) SCD30: CRC failed or Read error, retrying... (1)",CHECK
|
||||
19:44:02,1200.0,"CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",CHECK
|
||||
19:44:03,2500.0,"W (8393) SCD30: CRC failed or Read error, retrying... (0)",CHECK
|
||||
19:44:06,5000.0,"CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",CHECK
|
||||
23:02:18,400.0,"CO2: 400.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
|
||||
23:02:21,850.5,"CO2: 850.50 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
|
||||
23:02:23,1200.0,"CO2: 1200.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
|
||||
23:02:25,2500.0,"CO2: 2500.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
|
||||
23:02:27,5000.0,"CO2: 5000.00 ppm, Temp: 24.00 °C, Humidity: 50.00 %",PASS
|
||||
|
||||
|
42
run_test.py
42
run_test.py
@@ -3,7 +3,7 @@ import time
|
||||
from hil_lib import SCD30_HIL_Lib
|
||||
|
||||
# Device paths from your environment
|
||||
Device = 'HIL'
|
||||
Device = 'PC'
|
||||
|
||||
if Device == 'PC':
|
||||
EMULATOR = 'COM11'#'/dev/i2c_emulator'
|
||||
@@ -30,24 +30,48 @@ with open(LOG_FILE, mode='w', newline='') as f:
|
||||
for co2 in test_points:
|
||||
print(f"\n[PHASE] Setting Simulated CO2 to {co2} ppm")
|
||||
|
||||
# 1. Feed the bridge until the Target performs a successful Read
|
||||
# We loop briefly to wait for the Target's polling interval
|
||||
# Flush buffers to ensure we don't read old data
|
||||
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
|
||||
data_served = False
|
||||
target_msg = ""
|
||||
|
||||
while time.time() < timeout:
|
||||
# Service the Bridge
|
||||
if hil.process_bridge(co2, 24.0, 50.0):
|
||||
data_served = True
|
||||
|
||||
# Check for Target Output
|
||||
if hil.target.in_waiting:
|
||||
line = 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
|
||||
#time.sleep(4)
|
||||
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
|
||||
|
||||
# 2. Capture what the Target actually saw
|
||||
# Wait for Target to print the result to Serial
|
||||
time.sleep(0.5)
|
||||
target_msg = hil.get_target_reading()
|
||||
|
||||
# 3. Simple Validation
|
||||
status = "PASS" if str(int(co2)) in target_msg else "CHECK"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user