I’d like to send data over the USB-serial interface from an Arduino Uno/Nano to my PC. I found the uart-usb block and implemented what I thought would print over USB to the PC, but I got an error.
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227707999_sketch/xod_1557227707999_sketch.ino:1806:22: error: request for member 'begin' in '* state->xod::xod__uart__uart_usb::State::uart', which is of non-class type 'int'
state->uart->begin();
^
Error: exit status 1
Compilation failed.
Compilation failed
Command `/opt/XOD\ IDE/resources/arduino-cli --config-file=/tmp/arduino-cliOaFk8V/.cli-config.yml compile --fqbn arduino:avr:uno --verbose /tmp/xod_temp_sketchbookh5AAy6/xod_1557227707999_sketch` failed 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.
There’s more to the stack trace, but I didn’t want to flood this post with the whole trace. I can post it if needed. I’m so new to XOD I don’t know if my patch is even close to right, and the only examples I’ve found online are for serial communication between two Arduinos. I’m running version 0.29.1 of the XOD IDE.
Begin compiling code for the board Arduino/Genuino Uno 📦
Using board 'uno' from platform in folder: /home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21
Using core 'arduino' from platform in folder: /home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21
Detecting libraries used...
/home/jwright/xod/__packages__/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/cores/arduino -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/variants/standard /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/sketch/xod_1557227849531_sketch.ino.cpp -o /dev/null
Generating function prototypes...
/home/jwright/xod/__packages__/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/cores/arduino -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/variants/standard /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/sketch/xod_1557227849531_sketch.ino.cpp -o /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/preproc/ctags_target_for_gcc_minus_e.cpp
/home/jwright/xod/__packages__/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/home/jwright/xod/__packages__/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/cores/arduino -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/variants/standard /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/sketch/xod_1557227849531_sketch.ino.cpp -o /tmp/arduino-sketch-E9F2EAFBFC762880BDD0722ACEDBD130/sketch/xod_1557227849531_sketch.ino.cpp.o
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In constructor 'xod::xod__debug__tweak_string_16::State::State()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1153:24: error: array used as initializer
State() : view(buff) {}
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: At global scope:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1368:5: error: 'Serial_' does not name a type
Serial_ _serial;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1373:21: error: expected ')' before 'serial'
UsbUart(Serial_ serial, long baud = 9600)
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1406:5: error: 'Serial_' does not name a type
Serial_* toUsbSerial() {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::available()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1383:22: error: '_serial' was not declared in this scope
return (bool)_serial.available();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::writeByte(uint8_t)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1387:22: error: '_serial' was not declared in this scope
return (bool)_serial.write(byte);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::readByte(uint8_t*)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1391:20: error: '_serial' was not declared in this scope
int data = _serial.read();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::begin()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1413:5: error: '_serial' was not declared in this scope
_serial.begin(getBaudRate());
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::end()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1417:5: error: '_serial' was not declared in this scope
_serial.end();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::flush()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1420:5: error: '_serial' was not declared in this scope
_serial.flush();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: At global scope:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1428:26: error: 'Serial_' was not declared in this scope
struct ChooseUartWrapper<Serial_> {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1428:33: error: template argument 1 is invalid
struct ChooseUartWrapper<Serial_> {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1433:49: error: 'SerialUSB' was not declared in this scope
uint8_t mem[sizeof(ChooseUartWrapper<typeof SerialUSB>::UartT)];
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1433:58: error: template argument 1 is invalid
uint8_t mem[sizeof(ChooseUartWrapper<typeof SerialUSB>::UartT)];
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1434:30: error: 'SerialUSB' was not declared in this scope
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1434:39: error: template argument 1 is invalid
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1434:42: error: expected ';' at end of member declaration
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino: In function 'void xod::xod__uart__uart_usb::evaluate(xod::xod__uart__uart_usb::Context)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1533:35: error: 'struct xod::xod__uart__uart_usb::State' has no member named 'mem'
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1533:65: error: 'SerialUSB' was not declared in this scope
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1533:74: error: template argument 1 is invalid
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1534:48: error: no matching function for call to 'emitValue(xod::xod__uart__uart_usb::ContextObject*&, int*&)'
emitValue<output_UART>(ctx, state->uart);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1534:48: note: candidate is:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1508:33: note: template<class OutputT> void xod::xod__uart__uart_usb::emitValue(xod::xod__uart__uart_usb::Context, typename xod::xod__uart__uart_usb::ValueType<OutputT>::T)
template<typename OutputT> void emitValue(Context ctx, typename ValueType<OutputT>::T val) {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1508:33: note: template argument deduction/substitution failed:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1534:48: note: cannot convert 'state->xod::xod__uart__uart_usb::State::uart' (type 'int*') to type 'xod::xod__uart__uart_usb::ValueType<xod::xod__uart__uart_usb::output_UART>::T {aka xod::Uart*}'
emitValue<output_UART>(ctx, state->uart);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch/xod_1557227849531_sketch.ino:1538:22: error: request for member 'begin' in '* state->xod::xod__uart__uart_usb::State::uart', which is of non-class type 'int'
state->uart->begin();
^
Error: exit status 1
Compilation failed.
Compilation failed
Command `/opt/XOD\ IDE/resources/arduino-cli --config-file=/tmp/arduino-cliOaFk8V/.cli-config.yml compile --fqbn arduino:avr:uno --verbose /tmp/xod_temp_sketchbookh5AAy6/xod_1557227849531_sketch` failed 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.
@cesars Thanks for the help. Your suggestion eliminated that tweak error, but more still remain. I forgot to mention that I’m on Ubuntu 18.04.
/home/jwright/xod/__packages__/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/cores/arduino -I/home/jwright/xod/__packages__/packages/arduino/hardware/avr/1.6.21/variants/standard /tmp/arduino-sketch-474461764F7EBBAC95E11CD6EB649512/sketch/xod_1557248877405_sketch.ino.cpp -o /tmp/arduino-sketch-474461764F7EBBAC95E11CD6EB649512/sketch/xod_1557248877405_sketch.ino.cpp.o
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1281:5: error: 'Serial_' does not name a type
Serial_ _serial;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1286:21: error: expected ')' before 'serial'
UsbUart(Serial_ serial, long baud = 9600)
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1319:5: error: 'Serial_' does not name a type
Serial_* toUsbSerial() {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::available()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1296:22: error: '_serial' was not declared in this scope
return (bool)_serial.available();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::writeByte(uint8_t)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1300:22: error: '_serial' was not declared in this scope
return (bool)_serial.write(byte);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual bool xod::xod__uart__uart_usb::UsbUart::readByte(uint8_t*)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1304:20: error: '_serial' was not declared in this scope
int data = _serial.read();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::begin()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1326:5: error: '_serial' was not declared in this scope
_serial.begin(getBaudRate());
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::end()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1330:5: error: '_serial' was not declared in this scope
_serial.end();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In member function 'virtual void xod::xod__uart__uart_usb::UsbUart::flush()':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1333:5: error: '_serial' was not declared in this scope
_serial.flush();
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: At global scope:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1341:26: error: 'Serial_' was not declared in this scope
struct ChooseUartWrapper<Serial_> {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1341:33: error: template argument 1 is invalid
struct ChooseUartWrapper<Serial_> {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1346:49: error: 'SerialUSB' was not declared in this scope
uint8_t mem[sizeof(ChooseUartWrapper<typeof SerialUSB>::UartT)];
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1346:58: error: template argument 1 is invalid
uint8_t mem[sizeof(ChooseUartWrapper<typeof SerialUSB>::UartT)];
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1347:30: error: 'SerialUSB' was not declared in this scope
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1347:39: error: template argument 1 is invalid
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1347:42: error: expected ';' at end of member declaration
ChooseUartWrapper<typeof SerialUSB>::UartT* uart;
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino: In function 'void xod::xod__uart__uart_usb::evaluate(xod::xod__uart__uart_usb::Context)':
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1446:35: error: 'struct xod::xod__uart__uart_usb::State' has no member named 'mem'
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1446:65: error: 'SerialUSB' was not declared in this scope
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1446:74: error: template argument 1 is invalid
state->uart = new (state->mem) ChooseUartWrapper<typeof SerialUSB>::UartT(SerialUSB, (uint32_t)getValue<input_BAUD>(ctx));
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1447:48: error: no matching function for call to 'emitValue(xod::xod__uart__uart_usb::ContextObject*&, int*&)'
emitValue<output_UART>(ctx, state->uart);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1447:48: note: candidate is:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1421:33: note: template<class OutputT> void xod::xod__uart__uart_usb::emitValue(xod::xod__uart__uart_usb::Context, typename xod::xod__uart__uart_usb::ValueType<OutputT>::T)
template<typename OutputT> void emitValue(Context ctx, typename ValueType<OutputT>::T val) {
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1421:33: note: template argument deduction/substitution failed:
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1447:48: note: cannot convert 'state->xod::xod__uart__uart_usb::State::uart' (type 'int*') to type 'xod::xod__uart__uart_usb::ValueType<xod::xod__uart__uart_usb::output_UART>::T {aka xod::Uart*}'
emitValue<output_UART>(ctx, state->uart);
^
/tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch/xod_1557248877405_sketch.ino:1451:22: error: request for member 'begin' in '* state->xod::xod__uart__uart_usb::State::uart', which is of non-class type 'int'
state->uart->begin();
^
Error: exit status 1
Compilation failed.
Compilation failed
Command `/opt/XOD\ IDE/resources/arduino-cli --config-file=/tmp/arduino-cliOaFk8V/.cli-config.yml compile --fqbn arduino:avr:uno --verbose /tmp/xod_temp_sketchbookh5AAy6/xod_1557248877405_sketch` failed 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.
Yeah, this is so misguiding that it should be considered a bug.
The uart-usb node represents a USB serial on the boards having a dedicated CDC interface (like Leonardo or Micro). For Uno and Nano the interface is shared with UART #0. So, if you would use uart-0 instead of uart-usb, all should work fine for you.