is-available

xod/uart/is-available

Checks does UART have an available bytes to read
is-available
@/is-available
Checks does UART have an available bytes to read
UART@/uart
An UART object
UPDpulse
Check does UART have an available bytes to read
is-available
UART
UPD
Y
N
Npulse
Pulses when there is nothing to read from UART
Ypulse
Pulses when UART have available bytes

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto uart = getValue<input_UART>(ctx);
        bool available = uart->available();
        if (available) {
            emitValue<output_Y>(ctx, 1);
        } else {
            emitValue<output_N>(ctx, 1);
        }
    }
}