Compiler output / wrong line numbers?

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Compiler output / wrong line numbers?

Post by A.Harrenberg »

Hi,

I have not worked with the arduino compiler before and I have difficulties with the compiler output. In my sketch some warnings about "conversion from string literal to 'char *' is deprecated" pops up and I would like to understand which part of the sketch is triggering these warning to see how I can avoid theses warnings.

Code: Select all

SimpleDimmer_Multisensor_ah1.ino:55:16:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:59:16:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:62:16:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:67:18:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:69:18:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:71:16:warning:conversion from string literal to 'char *' is deprecated
SimpleDimmer_Multisensor_ah1.ino:74:16:warning:conversion from string literal to 'char *' is deprecated
(I think that) The line number reported are not correct...

If I look at the first numbers, line 55 is the closing paranthesis "}" of the loop() function, line 59 is a numeric calculation, line 62 is empty, line 67 is a "}" again, ...

If I create an error on purpose in e.g. line 116, an error in line 97 is reported, if I move the error to line 117 then line 98 is reported -> Offset 20 lines?

If I try to move the compiler error to the lines with the warnings I end up with an offset of 19 lines for these warnings, but if I create an error later in the file the offset is increased to 20.

So it "seems" that these warnings come from the serial.print function, but the "offset" also seems to vary / change during the code...

I know that these are only warnings, but if they were errors, how to point to the line of code that is triggering it? Is this a known problem with the arduino compiler? I tried to search a bit but did not find reports on wrong line numbers reported.

What is causing this "offset" and why is it changing?

Best regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Compiler output / wrong line numbers?

Post by PoltoS »

Have you tried 2.0.6? We have fixed many line number offsets.
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: Compiler output / wrong line numbers?

Post by A.Harrenberg »

Hi PoltoS,

yes, I am on 2.0.6 and the above was done with this version.

Regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Compiler output / wrong line numbers?

Post by PoltoS »

Please send us full sketch to test
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: Compiler output / wrong line numbers?

Post by A.Harrenberg »

Hi PoltoS,

here is my sketch, I made some slight modifications since I tested, but the issue is still there.

I added the sketch here in code-tags as files with *.ino are not allowed as attachments...
What would be the preferred way to "publish" a sketch? Renaming and as an attachment?

BTW, the warnings come from the Serial.print commands like this one, "Serial.print("Millis:");". By casting the string to (char *) the warning can be avoided, but I think that in newer arduino versions the lib changed to accept (const char *)...

Code: Select all

/*
 * This is based on the Simple Multilevel Dimmer example,
 * the dht22_test example, the Simple MultiSensor example
 * and the 1-wire DS18B20 example...
 * It gives you the ability to control the
 * built in LED brightness via Z-Wave commands
 * It should report values from the DHT11 sensor on the multisensor channnel
 */

// include DHT lib and declare DHT
#include "ZUNO_DHT.h"
DHT dht22_sensor(11, DHT11); // use pin 11, type of sensor = DHT11


// LED pin number
#define LED_PIN 13

// variable to store current dimmer value
byte lastSetDimmer;
float temperature = -99.0;
float humidity = -99.0;

// next macro sets up the Z-Uno channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_MULTILEVEL(getter, setter),
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE,
                         SENSOR_MULTILEVEL_SCALE_CELSIUS,
                         SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
                         SENSOR_MULTILEVEL_PRECISION_ONE_DECIMAL,
                         getterTemp),
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_RELATIVE_HUMIDITY,
                         SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE,
                         SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
                         SENSOR_MULTILEVEL_PRECISION_ONE_DECIMAL,
                         getterHum)
);
ZUNO_SETUP_DEBUG_MODE(DEBUG_ON);

void setup() {
  pinMode(LED_PIN, OUTPUT); //set up LED pin as output

  Serial.begin();
  dht22_sensor.begin();
}
void loop() {
  read_DHT();
  zunoSendReport(2); // report the temperature in channel 2
  zunoSendReport(3); // report the relative humidity in channel 3
  delay (31000);
}

word getterTemp() {
  word t;
  t = (word)(10.0 * temperature);
  return t;
}

word getterHum() {
  word h;
  h = (word)(10.0 * humidity);
  return h;
}

void read_DHT() {
  byte result;
  byte i;
  byte  raw_data[5];

  Serial.print("Millis:");
  Serial.println(millis());

  result = dht22_sensor.read(true);
  Serial.print("DHT read result:");
  Serial.println(result);
  if (result == 0) {
    Serial.print("Raw data: { ");
    dht22_sensor.getRawData(raw_data);
    for (i = 0; i < 5; i++)
    {
      Serial.print(raw_data[i], HEX);
      Serial.print(" ");
    }
    Serial.println("} ");

    Serial.print("Temperature:");
    temperature = dht22_sensor.readTemperature();
    Serial.println(temperature);
    Serial.print("Humidity:");
    humidity = dht22_sensor.readHumidity();
    Serial.println(humidity);
  }
}

// setter function is called once a command comes
// from the Z-Wave controller or over controlling device
void setter(byte value) {
  byte tempVariable;
  if (value > 99) {
    // by Z-Wave specification, this value can't be more then 99
    value = 99;
  }
  // but the LED brightness scale ranges from 0 to 255
  // we need to prepare our "value" for this new scale
  tempVariable = ((word)value) * 255 / 99;

  // now we set the LED brightness
  analogWrite(PWM1, ((long)value) * 255 / 99);

  // let's save our value for the situation, when the controller will ask us about it
  lastSetDimmer = value;
  getter();
}

// getter function is called once the controller
// or other device in the network asks Z-Uno about
// it's current level
byte getter(void) {
  // return previously saved (in getter()) value
  return lastSetDimmer;
}
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Compiler output / wrong line numbers?

Post by PoltoS »

I see. ZUNO_SETUP_CHANNELS is changed to one line in our preprocessor. Will change it in next release
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: Compiler output / wrong line numbers?

Post by A.Harrenberg »

Thnx for the investigation, in the meantime I will change it manually to one line...
fhem.de - ZWave development support
Post Reply