Hello everyone! There is no way I can solve my problem. I need to create a node that can form a mutable array from input data. For example, in the array from which the n-th element can be output, it is necessary to put different values of the coordinates that are given to one input. The size of the array must be variable. The data must be of the form “int”. I tried to do it via C++, but I don’t have enough experience yet and nothing good came out. Therefore, the “number” input receives new values, and by the “UPD” signal, places them with a scroll in the “n” length array. At the “IDX” input, we indicate the number of the element of the array that is displayed at the “idx” output. What can you advise?
This is difficult to do on a micro-processor with limited memory. If you want to use an array, you need to specify a maximum length when you create the array. If you don’t want to specify a maximum, then you need to allocate memory each time you push a value into the “array”. This could be done with linked lists or other options, but one too many calls to allocate more memory, and your program is going to crash because it is out of memory, and it is going to fail in very unpredictable ways. This option is also going to use a lot more memory than an array to store the same amount of information because you are going to need to save pointers to each index position as well as the data itself.
I also want to ask about this library: awgrover/buffer1 @1.0.0. Have you ever worked with it, and is it possible to try its nodes as a way to work with an array?
I have not used it, but it looks close to what you want. It does require specifying a maximum size for the array/buffer at boot time.
When you try to run the simulation, you get the following errors:
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:995:9: error: unknown type name ‘byte’
byte *buffer;
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:1106:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/buffer1 tried to allocate 0 bytes\n”)); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:1889:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:1889:43: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:1889:78: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2174:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“fill”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2174:43: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“fill”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2174:74: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“fill”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2347:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2347:43: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2347:78: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“set-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2761:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2761:43: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:2761:78: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-byte”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:3042:9: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:3042:43: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
/ws/sketchbook/27fa76c199b03391c032edbaef0d212ecbd3d4318d4385ef3a91d342254cfb61/sketch/sketch.ino:3042:78: error: use of undeclared identifier ‘DEBUG_SERIAL’
DEBUG_SERIAL.print(F(“buffer1/”));DEBUG_SERIAL.print(F(“get-word”)); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
^
17 errors generated.
shared:ERROR: ‘/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=1 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/libcxx -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/lib/libcxxabi/include -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/compat -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/libc -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/local/include -DLLVM_ROOT=/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/bin -DARDUINO_WASM_SIMULATION -DARDUINO_ARCH_WASM -O2 -std=c++11 -nostdlib -fno-exceptions -fno-rtti -c -I/tmp/arduino-sketch-3E9D75CEB429C9C83B4F6D7D260CA5ED/sketch -I/ws/arduino_data/packages/xod/hardware/wasm/0.3.2/cores/simulation -I/ws/arduino_data/packages/xod/hardware/wasm/0.3.2/variants/simulation -DEMSCRIPTEN /tmp/arduino-sketch-3E9D75CEB429C9C83B4F6D7D260CA5ED/sketch/sketch.ino.cpp -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/SDL -c -o /tmp/arduino-sketch-3E9D75CEB429C9C83B4F6D7D260CA5ED/preproc/ctags_target_for_gcc_minus_e.cpp -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr’ failed (1)
Error during build: exit status 1
When you try to run the simulation, you get the following errors:
The generated C++ code contains errors. It can be due to a bad node implementation
or if your board is not compatible with XOD runtime code. The original compiler error
message is above. Fix C++ errors to continue. If you believe it is a bug, report the
problem to XOD developers.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.