Impossible to compile an official example file

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
Gbajolet
Posts: 12
Joined: 29 Apr 2020 13:14

Impossible to compile an official example file

Post by Gbajolet »

Hello Everybody,

I just started with Z-Uno and I am very impressed by the potential possibilities, I would like to start a big project with Water consumption for my garden, fountain flow adjustement, water level in a big tank, etc...but now, I am trying to test some different sketches, as a base for my future project.

I already dowloaded several project some of them run and some other failed without known Reason (from me)

One of them is the Water meter example for Hot and Cold Water: the compiler returned me some mistakes, I would like to found some help for this, for information, I didn't touch the programming.

I attached the result of compilation, With some other program, I didn't meet problem.

Thank you by advance for your support

Gilles

here the message of the compiler:

Arduino : 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Carte : "Z-Wave>ME Z-Uno, Europe, Disabled, Disabled, Disabled, Disabled"

************* Building Arduino Sketch *************
C:\Users\bajol\AppData\Local\Temp\arduino_build_899743/WaterMeter.ino
***************************************************
--- USING a list of libraries from:
C:\Users\bajol\Documents\ArduinoData\packages\Z-Uno\hardware\zw8051\2.1.5\libraries
C:\Users\bajol\Documents\Arduino\libraries
*** Collecting prototypes...
Preprocessing file: Custom.c with SDCPP...
Preprocessing file: Print.cpp with SDCPP...
Compiling Print_sdcpp_.cpp ...
Preprocessing file: Stream.cpp with SDCPP...
Compiling Stream_sdcpp_.cpp ...
Preprocessing file: HardwareSerial.cpp with SDCPP...
Compiling HardwareSerial_sdcpp_.cpp ...
Preprocessing file: HLCore.cpp with SDCPP...
Compiling HLCore_sdcpp_.cpp ...
Preprocessing file: EEPROM.cpp with SDCPP...
Compiling EEPROM_sdcpp_.cpp ...
Preprocessing file: WaterMeter.cpp with SDCPP...
Compiling WaterMeter_sdcpp_.cpp ...
Preprocessing file: ZWSupport.cpp with SDCPP...
Compiling ZWSupport_sdcpp_.cpp ...
ZWSupport_sdcpp_.cpp:873:4:error:no matching function for call to 'resetterCold'
ZWSupport_sdcpp_.cpp:877:4:error:no matching function for call to 'resetterHot'
uCxx returned error code:1

exit status 1
Erreur de compilation pour la carte Z-Wave>ME Z-Uno

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.

Code: Select all

/*
 * This is a simple 2 chennel meter example
 * (c) Z-Wave.Me 2016
 */
 
#include <EEPROM.h>

// channel number
#define ZUNO_CHANNEL_NUMBER_COLD   1
#define ZUNO_CHANNEL_NUMBER_HOT    2

#define PIN_COLD    0
#define PIN_HOT     1

#define PIN_PULSE   13

#define EEPROM_ADDR             0x800
#define EEPROM_UPDATE_INTERVAL  120000

#define TICK_VALUE              10 // in liters


struct meter_data
{
    unsigned long ticks_cold;
    unsigned long ticks_hot;
    byte          crc8;
};

meter_data my_meter_data;

unsigned long last_update_millis = 0;
byte data_updated  = FALSE;

#define DEBOUNCE_COUNT  3
byte cold_triggered = 0;
byte cold_debounce = DEBOUNCE_COUNT;
byte hot_triggered = 0;
byte hot_debounce = DEBOUNCE_COUNT;



// next macro sets up the Z-Uno channels
// in this example we set up 1 meter channel
// you can read more on http://z-uno.z-wave.me/Reference/ZUNO_SENSOR_MULTILEVEL/
ZUNO_SETUP_CHANNELS(ZUNO_METER(ZUNO_METER_TYPE_WATER, METER_RESET_ENABLE, ZUNO_METER_WATER_SCALE_METERS3, METER_SIZE_FOUR_BYTES, METER_PRECISION_THREE_DECIMALS, getterCold, resetterCold),
                    ZUNO_METER(ZUNO_METER_TYPE_WATER, METER_RESET_ENABLE, ZUNO_METER_WATER_SCALE_METERS3, METER_SIZE_FOUR_BYTES, METER_PRECISION_THREE_DECIMALS, getterHot, resetterHot));


// For some cases use UART (Serial0/Serial1)
// It's a most comfortable way for debugging
// By default we use built-in USB CDC (Serial)
#define MY_SERIAL Serial

byte my_crc8(byte * data, byte count)
{
    byte result = 0xDF;

    while(count--)
    {
        result ^= *data;
        data++;
    }
    return result;
}
void update_meter_data()
{ 
    my_meter_data.crc8 = my_crc8((byte*)&my_meter_data, sizeof(meter_data) - 1);
    EEPROM.put(EEPROM_ADDR, &my_meter_data, sizeof(meter_data));
}
void setup() {
  MY_SERIAL.begin(115200);
  MY_SERIAL.println("Starting Meter...");

  // Dry contacts of meters connect to these pins
  pinMode(PIN_COLD, INPUT_PULLUP);
  pinMode(PIN_HOT, INPUT_PULLUP);

  // Get last meter values from EEPROM
  EEPROM.get(EEPROM_ADDR,  &my_meter_data, sizeof(meter_data));
  // Check data  
  if(my_crc8((byte*)&my_meter_data, sizeof(meter_data) - 1) != my_meter_data.crc8)
  {
      // Invalid data - reset all
      MY_SERIAL.println("Bad eeprom crc8 - init meter data");
      my_meter_data.ticks_cold = 0;
      my_meter_data.ticks_hot  = 0;
      update_meter_data();
            
  }
   
}



void loop() {


    if(!digitalRead(PIN_COLD))
    {
        if(!cold_triggered)
        {
          cold_debounce--;
          if(!cold_debounce)
          {
            my_meter_data.ticks_cold++;
            data_updated = true;
            cold_triggered = true;
            MY_SERIAL.println("Cold++");
            zunoSendReport(ZUNO_CHANNEL_NUMBER_COLD); 
          }
        }
    }
    else
    {
        cold_debounce = DEBOUNCE_COUNT;
        cold_triggered = false;

    }
    if(!digitalRead(PIN_HOT))
    {
        if(!hot_triggered)
        {
          hot_debounce--;
          if(!hot_debounce)
          {
            my_meter_data.ticks_hot++;
            data_updated = true;
            hot_triggered = true;
            MY_SERIAL.println("Hot++");
            zunoSendReport(ZUNO_CHANNEL_NUMBER_HOT); 
          }
        }

    }
    else
    {
        hot_debounce = DEBOUNCE_COUNT;
        hot_triggered = false;

    }
    // To save EEPROM from a lot of r/w operation 
    // write it once in EEPROM_UPDATE_INTERVAL if data was updated
    if(data_updated && ( millis() - last_update_millis ) > EEPROM_UPDATE_INTERVAL )
    {
        update_meter_data();
        data_updated = false;
        last_update_millis =  millis();
        MY_SERIAL.println("Updating EEPROM");
    }
    delay(100);
   
}


void resetterCold(byte v) {
  my_meter_data.ticks_cold = 0;
  update_meter_data();
  MY_SERIAL.println("Cold meter was reset");
}
void resetterHot(byte v) {
  my_meter_data.ticks_hot  = 0;
  update_meter_data();
  MY_SERIAL.println("Hot meter was reset");
}

unsigned long getterCold(void) {
  return my_meter_data.ticks_cold*TICK_VALUE;
}
unsigned long getterHot(void) {
  return my_meter_data.ticks_hot*TICK_VALUE;
}
User avatar
PoltoS
Posts: 7594
Joined: 26 Jan 2011 19:36

Re: Impossible to compile an official example file

Post by PoltoS »

Looks like void resetterHot(byte v) should be changed to void resetterHot(void)
Gbajolet
Posts: 12
Joined: 29 Apr 2020 13:14

Re: Impossible to compile an official example file

Post by Gbajolet »

Dear PoltoS,

Thank you very much, as proposed, I change resetterHot and resetterCold and the compilation run. If you have 1 minute, could you explain?

Thank you

Gilles

Code: Select all

void resetterCold(void) {
  my_meter_data.ticks_cold = 0;
  update_meter_data();
  MY_SERIAL.println("Cold meter was reset");
}
void resetterHot(void) {
  my_meter_data.ticks_hot  = 0;
  update_meter_data();
  MY_SERIAL.println("Hot meter was reset");
}
Post Reply