Isue / Bug in message.getInt or getFloat/ payload dos not reinitialized completely?



  • Hi, i think it is abug in message.getInt/ Get Float because... after couple of times from reading a int value it gets the rest of a float before ...

    example
    it reads allways a value 10 with getInt

    then a temp sensor sends a value 47.28

    after the getInt value gets 1028

    check here:

    i send to node 0/13 ALLWAYS "0" and after 10sec "-20.20"
    if i take get Float it gets FUNNY numbers like (see in the code):
    20.20 or 1.28 etc..

    im pwm
    13
    -20.20
    im digital
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    20.20
    im digital
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/58/1/0/0
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/58/1/0/0
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    -20.20
    im digital
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    20.20
    im digital
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    -20.20
    im digital
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/58/1/0/0
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/58/1/0/0
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    1.28
    im digital
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    13
    -20.20
    im digital
    

    node receives on child id
    always the number after the "." (in this case 28) gets as add to int value of 10...So it gets 1028

    could you please check! can send you my sketch if you like!



  • here anothe example (getFloat)
    i'm sending 1.1 and -20.20)

    geting sometimes right values but sometimes:

    
    im pwm
    13
    1.18
    im digital
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/13/1/0/3
    im pwm
    
    

    So somehow it doesnt see the "0" and writes something from the last value!



  • If i send 10 or 100 (so MANY ZERO's) with getFloat

    it gets COMPLETly CRAZY!

    10073.00
    im digital
    
    13
    10061.00
    
    13
    10062.00
    
    
    13
    10050.00
    
    
    im pwm
    13
    10084.00
    
    

  • Admin

    Might be related to this:
    https://github.com/mysensors/Arduino/pull/317

    tekka007 created this issue in mysensors/Arduino

    closed Fix null termination issue #317



  • checking!



  • same issue!!!!
    NO changes!



  • changed to the NEW ->>>MYTransport.cpp from Pull!

    sending -2 and 10 as float to arduino:
    13
    -2.73

    13
    10.73
    im digital

    13
    -2.73
    13
    10.73
    im digital

    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/58/1/0/0 as Float!!!!!!!!!!

    13
    -2.72
    im digital



  • please tell us when is solved, because i have made a Sketch to use ALL of the sensors with MQTT! But with this issue NOBODY could yuse it...

    Just a part of te code;

    void receive(const MyMessage &message)
    {
      int childPin = message.sensor;
      //  Serial.println(message.getBool());
      //  Serial.println(message.sensor);
      for (int i = 0; i<iomodus_count; i++) ////search All Sensor Variables and set them
      { //MyMessage msg(i, iomodus[i].variableType);
        while (iomodus[i].sensorType == S_UNUSED) { i++; }  //do not waste time to check UNUSED pins
    
                                  //********************************IF VAR1 = Temp OFFSET existst*************************************** 
        if (message.type == V_VAR1)
        {
          if ((childPin == i) && (iomodus[i].sensorType == S_TEMP) && (iomodus[i].sensorVersion == "MAX31855"))
          {
            Temp_offset[i] = message.getFloat();
          }
        }
        if (message.type == V_VAR1)
        {
          if ((childPin == i) && (iomodus[i].sensorType == S_TEMP) && (iomodus[i].sensorVersion == "NTC"))
          {
            Temp_offset[i] = message.getFloat();
          }
        }
        //********************************IF VAR2 = LPF (Low Pass Filter existst*************************************** 
        if (message.type == V_VAR2)
        {
          //***************Low Pass Filter**************
          if ((childPin == i) && (iomodus[i].sensorType == S_TEMP) && (iomodus[i].sensorVersion == "MAX31855") && (message.getFloat() <= 1.0))
          {
            ktype_LPF_rate[i] = message.getFloat();
          }
        }
        //********************************IF V_STATUS or V_LIGHT existst*************************************** 
        if (message.type == V_STATUS)
        {
          if ((childPin == i) && (iomodus[i].sensorType == S_BINARY) && (iomodus[i].sensorVersion == "RELAY"))
          {
            if (relstate[i] != message.getBool())
            {
              digitalWrite(i, message.getBool() ? RELAY_ON : RELAY_OFF);
              relstate[i] = message.getBool();
              // Store state in eeprom
              saveState(i, message.getBool());
            }
          }
        }
        //********************************IF V_PERCENTAGE or V_DIMMER existst*************************************** 
        if ((message.type == V_PERCENTAGE) && (message.getInt() <= 100) && (message.getInt() != last_int_value[i]))
        {
          //***************PWM Rate 0 to 100 (%)**************  
          if ((childPin == i) && (iomodus[i].sensorVersion == "PWM")&& (i<=13))
          {
              pinMode(i, OUTPUT);
              analogWrite(i, message.getInt()*2.25); // Set Value 0-255
              last_int_value[i] = value;
          }
          //http://www.instructables.com/id/Analog-Output-Convert-PWM-to-Voltage/
          if ((childPin == i) && (iomodus[i].sensorVersion == "PWM_5V") && (i >= 54) && (i >= 69))
            { 
              pinMode(i, OUTPUT);
              analogWrite(i, message.getInt()*2.55); // Set Value 0-255
              last_int_value[i] = value;
            }
    
        }
    

    HERE is the problem!!!!

    message.getInt()

    we can not use this function, if i use later in the void loop this:

    				MyMessage msg(i, iomodus[i].variableType);
    				send(msg.setSensor(i).set(tempNTC, 2), 0);
    
    because parts of this value float tempNTC are attached to the integer value above!
    
    so it would be very cool if you could solve this issue!
    
    Thank you!


  • Update...

    to find the BUG maybe it will help:
    I noticed that after a float value publisching, the "Dirt" is only staying until the next value:

    here is ok

    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/11/1/1/15
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/11/1/1/15
    message
    1.00
    

    here comes the float:

    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/58/1/1/0
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/58/1/1/0
    message
    40.84
    

    here comes the DIRT (8 should be ZERO:

    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/8/1/1/2
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/8/1/1/2
    message
    0.84
    

    here is the DIRT gone:

    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/10/1/1/77
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/10/1/1/77
    message
    0.00
    0;255;3;0;9;Message arrived on topic: DOino<>MQTT/0/11/1/1/77
    0;255;3;0;9;Sending message on topic: DOino<>MQTT/0/11/1/1/77
    message
    11
    0
    0.00
    

    but funy is, that the MQTT Server does NOT get any dirt :

    mqtt-0	2016-01-03 09:38:33	info	Send to client [mqtt_fd810ccf.027ef] "mqtt/0/DOino<>MQTT/0/8/1/1/2": 0
    mqtt-0	2016-01-03 09:38:33	info	Send to client [DOino_1] "DOino<>MQTT/0/8/1/1/2": 0
    

    from this float:

    mqtt-0	2016-01-03 09:38:33	info	Client [DOino_1] _publishes "mqtt.0.DOino<>MQTT.0.58.1.1.0"(number): 40.84
    mqtt-0	2016-01-03 09:38:33	info	Send to client [mqtt_fd810ccf.027ef] "mqtt/0/DOino<>MQTT/0/58/1/1/0": 40.84
    mqtt-0	2016-01-03 09:38:33	info	Send to client [DOino_1] "DOino<>MQTT/0/58/1/1/0": 40.84```

Log in to reply
 

Suggested Topics

  • 5
  • 48
  • 7
  • 182
  • 1
  • 10
  • 4
  • 85

125
Online

10.6k
Users

10.8k
Topics

111.1k
Posts