set-5bytes-buffer1

nazarijtipusak080/set-5bytes-buffer1/set-5bytes-buffer1

No description
set-5bytes-buffer1
@/set-5bytes-buffer1
buffer1nazarijtipusak080/buffer1/buffer1
val1byte
val2byte
val3byte
val4byte
val5byte
beginnumber
triggerpulse
set-5bytes-buffer1
buffer1
val1
val2
val3
val4
val5
begin
trigger
buffer
done
ERR
ERRpulse
donepulse
buffernazarijtipusak080/buffer1/buffer1
To use the node in your project you should have the nazarijtipusak080/set-5bytes-buffer1 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

//-- void buffer1::set_byte(value, i)
// Our constructor namespace should be: buffer1_ll__buffer1
struct State {
  // not used
  };

{{ GENERATED_CODE }}

void evaluate(Context ctx) {

  // only act on trigger, inputs not relevant for this
  if ( !isInputDirty<input_trigger>(ctx) ) return;

  char value1 = getValue<input_val1>(ctx); // char
    char value2 = getValue<input_val2>(ctx);
    char value3 = getValue<input_val3>(ctx);
    char value4 = getValue<input_val4>(ctx);
    char value5 = getValue<input_val5>(ctx);
  uint16_t i = static_cast<uint16_t> (getValue<input_begin>(ctx));
  auto _object = getValue<input_buffer1>(ctx); // buffer1

  //DEBUG_SERIAL.print(F("set @")); DEBUG_SERIAL.print((long) _object->buffer);DEBUG_SERIAL.print(F("/"));DEBUG_SERIAL.print(_object->len);
  //DEBUG_SERIAL.print(F("["));DEBUG_SERIAL.print((int)i);DEBUG_SERIAL.print(F("]="));DEBUG_SERIAL.print((int)value,HEX);
  //DEBUG_SERIAL.print(F("\n"));
  if ( ! _object->buffer ) {
    //DEBUG_SERIAL.print(F("buffer1/"));DEBUG_SERIAL.print(F("set-byte")); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
  }
  else if ( i < 0 || (i+4) >= _object->len ) {
    emitValue<output_ERR>(ctx, 1); // pulse
  }
  else {
    _object->buffer[i] = value1;
       _object->buffer[i+1] = value2;
       _object->buffer[i+2] = value3;
       _object->buffer[i+3] = value4;
       _object->buffer[i+4] = value5;
    emitValue<output_done>(ctx, 1); // pulse
  }
  emitValue<output_buffer>(ctx, _object); // convenience
}