How to wait for a condition on an input port