has-available-byte

xod-dev/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
To use the node in your project you should have the xod-dev/w5500 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_CHK

#include <SPI.h>
#include <Ethernet2.h>

node {
    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);
        }
    }
}