get-byte-from-packet

gabbapeople/simple-byte-protocol/get-byte-from-packet

Pulls a byte value from a packet depending on the sequence number
get-byte-from-packet
@/get-byte-from-packet
Pulls a byte value from a packet depending on the sequence number
IN@/packet
IDXnumber
Sequence number of the byte to pull from a packet
GETpulse
Triggers a new pull of a byte
get-byte-from-packet
IN
IDX
GET
BYTE
BYTEbyte
To use the node in your project you should have the gabbapeople/simple-byte-protocol 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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (isInputDirty<input_GET>(ctx)){
        auto _packet = getValue<input_IN>(ctx);
        uint8_t idx = getValue<input_IDX>(ctx);
        if (idx > 0 && (idx < _packet.bufferSize - 1)){
            emitValue<output_BYTE>(ctx, _packet.buffer[idx]);
        }
    }
}