Compiling for Z.Uno throws error


I am attempting to modify the Adafruit library for a VEML6070 sensor to get the library to compile and run on a Z.Uno device. The .h file I am adapting has the following code to create a C++ union:

  typedef union {
    struct {
      uint8_t SD:1;
      uint8_t :1;
      uint8_t IT:2;
      uint8_t ACK_THD:1;
      uint8_t ACK:1;
    } bit;
    uint8_t reg;

  } commandRegister;

  commandRegister _commandRegister;

This is used to set the i2c address of the device and bits of the structure during runtime. Unfortuately, when trying to compile the code the preprocessor runs into this condition:

sdcc: Calling preprocessor...

sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Karl\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80/zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Karl\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80/zuno_toolchain/sdcc/\bin\..\include"  "C:\Users\Karl\AppData\Local\Temp\arduino_build_611864\ZUNO_VEML6070_ucxx.c" 

sdcc: Generating code...

sdcpp.exe: fatal error: when writing output to : Broken pipe

strncpyz prevented buffer overrun!

C:\Users\Karl\AppData\Local\Temp\arduino_build_355225\ZUNO_VEML6070_ucxx.c:647: syntax error: token -> ':' ; column 27

Error. SDCC returned: 1

exit status 1
Error compiling for board Z-Wave>ME Z-Uno.

The line of code where it is complaining looks like this:

typedef struct cxx__class__ZUNO_VEML6070_s 
     cxx__class__TwoWire * _i2c;
     struct ZUNO_VEML6070::commandRegister _commandRegister;


The definition of the structure

 struct ZUNO_VEML6070::commandRegister _commandRegister;

is causing the grief during preprocessing.

Could it be that the compiler is having an issue with the definition of the union and structure? Does anybody have any suggestions on how to work around this? Is this something that needs to be raised with the makers of the board?

Any help and direction is greatly appreciated.


Karl Baker

I don't know the Z-Uno development platform, but was curious enough to spend a few minutes poking around. I could find no neutral review of it all and could not even find out what MCU architecture is used. All I see is a reference to a "C-like" programming language which is supported as add-in to the Arduino development environment.

OK. Having said that, the other thing is that Adafruit libraries can be extremely complex ways of achieving simple things.

In your case, you have an ultra violet sensor VEML6070 which uses an I2C protocol to read and write to it. Start with the data sheet of the VEML6070 and it shows how to read and write from the device registers. You can also try a Google search which turns up other libraries for handling the same sensor. For example, seeedstudio also support it.

If you want to continue the Adafruit library route, you have to give more information.
From your code snippets, it is not really clear how you are attempting to integrate the Adafruit library. Is ZUNO_VEML6070 a namespace of your own creation ?

Maybe a better starting point would be to look at the Z-Uno implementation of the BH1750 light sensor and adapt a copy of that to function with the VEML607. These sensors appear reasonably similar and are relatively simple I2C sensor devices. You'll need to get the data sheets for both these sensors to see the differences.