has-available-byte

xod/w5500/has-available-byte

Checks if there is any incoming data to be read with `read-byte`
has-available-byte
@/has-available-byte
Checks if there is any incoming data to be read with `read-byte`
SOCKxod/net/socket
The socket
CHKpulse
Perform the check
has-available-byte
SOCK
CHK
Y
N
Npulse
Pulses if there is no incoming data
Ypulse
Pulses if there is at least one byte

C++ implementation

{{#global}}
#include <SPI.h>
#include <Ethernet2.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

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

    auto client = EthernetClient(getValue<input_SOCK>(ctx));

    if (client.available()) {
        emitValue<output_Y>(ctx, 1);
    } else {
        emitValue<output_N>(ctx, 1);
    }
}