read-byte

xod-dev/w5500/read-byte

Read a single byte of the response from an opened connection Possible errors: — Can't receive the data from the socket
read-byte
@/read-byte
Read a single byte of the response from an opened connection Possible errors: — Can't receive the data from the socket
SOCKxod/net/socket
A socket
READpulse
Read the byte
read-byte
SOCK
READ
B
DONE
DONEpulse
Pulses when the byte is read
Bbyte
The last read 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_READ

#pragma XOD error_raise enable

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

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

        auto client = EthernetClient(getValue<input_SOCK>(ctx));
        uint8_t b = client.read();

        if (!b) {
            raiseError(ctx);
            return;
        }

        emitValue<output_B>(ctx, b);
        emitValue<output_DONE>(ctx, 1);
    }
}