DEIS-Tools / CLAIRE-library

GNU General Public License v3.0
0 stars 0 forks source link

[Python] Waiting in get state is unreliable #39

Closed magoorden closed 1 month ago

magoorden commented 1 month ago

Currently, in getting the state of the system, the Python driver waits a fix amount of time. But this is unreliable. If there was a state reading before and the current state hasn't been send yet, the old state is catched and returned.

magoorden commented 1 month ago

After changing the get state method to wait for response over serial, I got the following (truncated) output of an experiment.

DRIVER: Writing command: 1;
{"Tube0_water_mm": 430.70, "Tube1_water_mm": 904.90, "Tube0_inflow_duty": 10,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
DRIVER: Writing command: 1;
{"Tube0_water_mm": 413.30, "Tube1_water_mm": 905.00, "Tube0_inflow_duty": 10,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
DRIVER: Writing command: 1;
{"Tube0_water_mm": 397.10, "Tube1_water_mm": 905.60, "Tube0_inflow_duty": 10,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
DRIVER: Writing command: 4 1 0;
DRIVER: Writing command: 1;
{"Tube0_water_mm": 378.10, "Tube1_water_mm": 905.70, "Tube0_inflow_duty": 10,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
Time: 1721895960.243752; level: 521.9
Duration: 38.98082113265991; change: 270.5
Start flow calibration of tube 1 with duty level 10.
DRIVER: Writing command: 1;
{"Tube0_water_mm": 364.20, "Tube1_water_mm": 905.50, "Tube0_inflow_duty": 0,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
Start calibration.
Time: 1721895965.139168; level: 535.8
DRIVER: Writing command: 4 2 10;
DRIVER: Writing command: 1;
{"Tube0_water_mm": 364.60, "Tube1_water_mm": 905.60, "Tube0_inflow_duty": 0,"Tube0_outflow_duty": 0,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
{"Tube0_water_mm": 367.10, "Tube1_water_mm": 905.60, "Tube0_inflow_duty": 0,"Tube0_outflow_duty": 10,"Tube1_inflow_duty": 0,"Tube1_outflow_duty": 0,"Stream_inflow_duty": 0,"Stream_outflow_duty": 0}
DRIVER: Writing command: 3;
Emergency stop applied! Expect state of demonstrator to be undefined.

Each DRIVER: Writing command: 1; is followed by a state from the Arduino, except at the end, where two lines were returned. Note that I stopped the Python script manually, as it couldn't handle this unexpected behavior from the Arduino.