Help wrapping Arduino Libraries

Trying to write a XOD wrapper for

The 1st issue is that they put header files in a src sub-folder & XOD cannot find it. I’ve tried using #include <src\LX16AServo.h> instead of just #include <LX16AServo.h>, but that does not help. My short-term fix is to copy the .h & .cpp files up one folder so XOD can find them.

The 2nd issue is that the library uses Serial1, but XOD is complaining it is not defined:

C:\Users\gweimer\AppData\Local\Temp\xod_temp_sketchbookztURTw\libraries\lx16a_servo/LX16AServo.h:4:17: error: 'Serial1' was not declared in this scope
         : _port(Serial1)

I see that it is defined here:

xod/packages/packages/arduino/hardware/avr/1.6.21/cores/arduino/HardwareSerial.h: extern HardwareSerial Serial1;

but adding #include <HardwareSerial.h> to my wrapper doesn’t help.

Here is what I have so far: lx16a-servo.xodball (8.7 KB) lx16a-example is how I see it being used.

I still haven’t found the reason for the folder, but if there is something that shouldn’t be

the declaration is in the three nodes of the example, usually the call is in a single node “device”

Another thing you notice is the use of
bus.begin() … for this type of design

bus->begin() is used

ps: I think that being hardwareserial should be a different implementation, type library Visi Genie,

try its

Rewrote to use sneekbot, and still having same problems. Header file needs copied to parent folder under __ardulib__ and Serial1 is still not defined:

C:\Users\gweimer\AppData\Local\Temp\xod_temp_sketchbookoFxJkS\libraries\sneekbot\ServoLX.cpp: In member function ‘void ServoLX::begin()’:
C:\Users\gweimer\AppData\Local\Temp\xod_temp_sketchbookoFxJkS\libraries\sneekbot\ServoLX.cpp:40:2: error: ‘Serial1’ was not declared in this scope

What micro are you compiling for? that error may not appear in a Mega

even if you don’t have a UNO, you can place Mega and compile, the compilation should have no error …just load error
check the implementation of “Init” for vision genie, it is complex but use nodo “Uart” de xod

I have an UNO. Oddly, there is only option for UNO WiFi in XOD now…

It does compile if I select Mega…just can’t deploy to UNO then. Having trouble figuring out franc0r library you suggested, but it looks like it uses software serial & would be a better option for me…

I also had the problem, when two libraries are needed, I cannot and did not know how to define two types

then I used soft serial and I made the deficiencies (without using Type),
in this case instead of using "->" is used "." and the development is very similar to what I would do in the arduino ide

ps: have you tried with Serial instead of Serial1?


class LX16ABus {
        : _port(Serial)   
        , _baud(115200)

I’m going to try programming it myself using soft-uart instead of using a library. Looks like most of the existing libraries are using hardware UART and are hard-coded for Serial1.

Bah…XOD doesn’t like franc0r library’s includes:

#include <iostream>
#include <vector>
#include <cstdint>
#include <optional>

I guess I’ll have to code this without any building on existing libraries unless someone can help me get one of these libraries working. The other libraries for lx16a servos either are not C++, or they are hard-coded for Serial1, which Arduino UNO apparently doesn’t support.

Next question…will XString handle binary data, or will I need to add my own data type for passing messages that will be sent to servo?

Maybe there is already a reference that I’m not seeing… stops way short of what I need.

I THINK what I want to do is create my own lx16a class just so I can define some inline code utilities (like calculating checksum) and create my own datatype for accessing this class. Everywhere I use this class, I also need to access UART, so I would like to pass in a UART to my lx16a-servo-device, add class to define public inline functions, then create a struct that stores both the class & UART so I can pass both as SERVO to my send & receive nodes.

Is this even close?

class Lx16a{
  inline static uint8_t checksum(const <uint8_t>& data)
     <dummy code>

struct State {
    uint8_t cmd[sizeof(Lx16a)];
    SoftwareUart* uart; 
void evaluate(Context ctx) {
    auto state = getState(ctx);
    state->uart = getValue<input_UART>(ctx);
    new (state->servo) Lx16a();
    emitValue<output_SERVO>(ctx, state);

How do we emit complex data? Can I emit state like above? When I use it in another node, can I access servo->uart and servo->cmd->checksum()?

Instead of passing my state data, do I need add UART to my new lx16a class?

Once I create the new joined data-type, how do I reference the parts?

Is there any existing documentation on creating/using joined data like this? Is there a good example I could be looking at?

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