byte-address-last

nazarijtipusak080/buffer1-byte-address/byte-address-last

Returns the address of the specified byte in the buffer (you can check part of the buffer by specifying an end-of-length limit in "last"). If a byte is repeated in the buffer, output the last of the addresses. If the specified byte is not in the buffer, outputs -1.
byte-address-last
@/byte-address-last
Returns the address of the specified byte in the buffer (you can check part of the buffer by specifying an end-of-length limit in "last"). If a byte is repeated in the buffer, output the last of the addresses. If the specified byte is not in the buffer, outputs -1.
buffer1nazarijtipusak080/buffer1/buffer1
valuebyte
lennumber
lastnumber
triggerpulse
byte-address-last
buffer1
value
len
last
trigger
i
done
ERR
ERRpulse
donepulse
inumber
To use the node in your project you should have the nazarijtipusak080/buffer1-byte-address 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_trigger>(ctx)) return;
 if (isInputDirty<input_trigger>(ctx)) emitValue<output_i>(ctx,(-1));
    // Отримуємо об'єкт буфера
    auto _object = getValue<input_buffer1>(ctx); // буфер
    uint16_t len = static_cast<uint16_t>(getValue<input_len>(ctx));
     uint16_t last = static_cast<uint16_t>(getValue<input_last>(ctx));
    char value = getValue<input_value>(ctx); // char
    // Перевірка, чи існує буфер і чи є правильна довжина
    if (!_object->buffer || len > _object->len) {
        emitValue<output_ERR>(ctx, 1);  // видаємо помилку
        return;
    }

    // Зсув байтів вліво
    for (int16_t i = 0; i < last; i++) {
      if ( _object->buffer[i] == value){
         emitValue<output_i>(ctx, i)  ;}
    }
    
   
    // Виводимо успіх
    emitValue<output_done>(ctx, 1);
}