XString not a string

I have an input value of type string. I thought so. But mine is some kind of XString, and I don’t know how to work with it at all. Or can it somehow be converted to a normal string?

error: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to ‘const String&’.

(Begin compiling code for the board Arduino Uno :package:

Using board ‘uno’ from platform in folder: C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3
Using core ‘arduino’ from platform in folder: C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3

Detecting libraries used…

“C:\Users\User\xod\packages\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\cores\arduino” “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\variants\standard” “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\sketch\xod_1594669991312_sketch.ino.cpp” -o nul

Generating function prototypes…

“C:\Users\User\xod\packages\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\cores\arduino” “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\variants\standard” “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\sketch\xod_1594669991312_sketch.ino.cpp” -o “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\preproc\ctags_target_for_gcc_minus_e.cpp”

“C:\Users\User\xod\packages\packages\builtin\tools\ctags\5.8-arduino11/ctags” -u --language-force=c++ -f - --c+±kinds=svpf --fields=KSTtzns --line-directives “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\preproc\ctags_target_for_gcc_minus_e.cpp”

Compiling sketch…

“C:\Users\User\xod\packages\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\cores\arduino” “-IC:\Users\User\xod\packages\packages\arduino\hardware\avr\1.8.3\variants\standard” “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\sketch\xod_1594669991312_sketch.ino.cpp” -o “C:\Users\User\AppData\Local\Temp\arduino-sketch-DB8180C72D4EFDC4A64D20D0A405DBF7\sketch\xod_1594669991312_sketch.ino.cpp.o”

C:\Users\User\AppData\Local\Temp\xod_temp_sketchbookiCtAgu\xod_1594669991312_sketch\xod_1594669991312_sketch.ino: In function ‘void xod::____abcd::evaluate(xod::____abcd::Context)’:
C:\Users\User\AppData\Local\Temp\xod_temp_sketchbookiCtAgu\xod_1594669991312_sketch\xod_1594669991312_sketch.ino:1297:32: error: no match for ‘operator=’ (operand types are ‘String’ and ‘xod::XString {aka xod::List}’)
c = getValue<input_IN1>(ctx);
^

In file included from C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/Arduino.h:232:0,
from C:\Users\User\AppData\Local\Temp\xod_temp_sketchbookiCtAgu\xod_1594669991312_sketch\xod_1594669991312_sketch.ino:18:
C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:86:11: note: candidate: String& String::operator=(const String&)
String & operator = (const String &rhs);
^~~~~~~~
C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:86:11: note: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to ‘const String&’
C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:87:11: note: candidate: String& String::operator=(const char*)
String & operator = (const char *cstr);
^~~~~~~~
C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:87:11: note: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to ‘const char*’
C:\Users\User\xod_packages_\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:88:11: note: candidate: String& String::operator=(const FlashStringHelper*)
String & operator = (const _FlashStringHelper *str);
^~~~~~~~
C:\Users\User\xod_packages
\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:88:11: note: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to 'const FlashStringHelper*’
C:\Users\User\xod_packages
\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:90:11: note: candidate: String& String::operator=(String&&)
String & operator = (String &&rval);
^~~~~~~~
C:\Users\User\xod_packages
\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:90:11: note: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to ‘String&&’
C:\Users\User\xod_packages
\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:91:11: note: candidate: String& String::operator=(StringSumHelper&&)
String & operator = (StringSumHelper &&rval);
^~~~~~~~
C:\Users\User\xod_packages
\packages\arduino\hardware\avr\1.8.3\cores\arduino/WString.h:91:11: note: no known conversion for argument 1 from ‘xod::XString {aka xod::List}’ to ‘StringSumHelper&&’

Error: exit status 1
Compilation failed.
Compilation failed
Command Process exited with code 1
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.)

The following code will read in an XString from an input called TEXT and convert it to a plain C string named cString.

auto xString = getValue<input_TEXT>(ctx);
int N=length(xString) + 1;
char cString[N];
for(int i=0;i<N;i++)
cString[i]=0;
dump(xString, cString);

Hope this helps. Thanks to @martinbrader for this solution.

Hi, @danya!
The XString in XOD is a List of <char> that can be iterated.
To dive deeper take a look at these headers:
listViews.h
listFuncs.h

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.