MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

Truncated message when arduino sending version info

Open damianchojna opened this issue 5 years ago • 7 comments

I check that in mMySensors arduino lib 2.3.2 on ArduinoMega, when i use node as MY_GATEWAY_SERIAL

Problem with the cut message when arduino send version info: 0;255;0;0;17;2 /*!< Major release vers

In Arduino/libraries/MySensors/core/Version.h, in MYSENSORS_LIBRARY_VERSION_MINOR is this truncated message. This makes mysensors in the home assistant not work.

Line 58: #define MYSENSORS_LIBRARY_VERSION STR(MYSENSORS_LIBRARY_VERSION_MAJOR) "." STR(MYSENSORS_LIBRARY_VERSION_MINOR) "." STR(MYSENSORS_LIBRARY_VERSION_PATCH) //!< final release versioning When I replace it with, this work for me. MYSENSORS_LIBRARY_VERSION "2.3.2"

This truncated information is correct behavior?

Arduino Code:

#define MY_GATEWAY_SERIAL
#define MY_REPEATER_FEATURE
#define MY_NODE_ID 0
#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>

#define RELAY_PIN  5
#define BUTTON_PIN  A0
#define CHILD_ID 1
#define RELAY_ON 1
#define RELAY_OFF 0

Bounce debouncer = Bounce();
bool state = false;
bool initialValueSent = false;

MyMessage msg(CHILD_ID, V_STATUS);

void setup()
{
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(10);

  // Make sure relays are off when starting up
  digitalWrite(RELAY_PIN, RELAY_OFF);
  pinMode(RELAY_PIN, OUTPUT);
}

void presentation()  {
  sendSketchInfo("Relay+button", "1.0");
  present(CHILD_ID, S_BINARY);
}

void loop()
{
  if (!initialValueSent) {
    Serial.println("Sending initial value");
    send(msg.set(state?RELAY_ON:RELAY_OFF));
    Serial.println("Requesting initial value from controller");
    request(CHILD_ID, V_STATUS);
    wait(2000, C_SET, V_STATUS);
  }
  if (debouncer.update()) {
    if (debouncer.read()==LOW) {
      state = !state;
      // Send new state and request ack back
      send(msg.set(state?RELAY_ON:RELAY_OFF), true);
    }
  }
}

void receive(const MyMessage &message) {
  if (message.isAck()) {
     Serial.println("This is an ack from gateway");
  }

  if (message.type == V_STATUS) {
    if (!initialValueSent) {
      Serial.println("Receiving initial value from controller");
      initialValueSent = true;
    }
    // Change relay state
    state = (bool)message.getInt();
    digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
    send(msg.set(state?RELAY_ON:RELAY_OFF));
  }
}

Serial Output:

0;255;3;0;14;Gateway startup complete.
0;255;0;0;17;2 /*!< Major release vers
0;255;3;0;11;Relay+button
0;255;3;0;12;1.0
0;1;0;0;3;

damianchojna avatar Feb 09 '20 16:02 damianchojna

Interesting. That line of code hasn't been changed since Sep 4, 2017.

mfalkvidd avatar Feb 09 '20 21:02 mfalkvidd

Cross-reference: https://forum.mysensors.org/topic/10934/truncated-message-when-arduino-sending-version-info

mfalkvidd avatar Feb 09 '20 21:02 mfalkvidd

Interesting! Just got something similar I think. I had a lot of issues trying to connect a new node to my gateway. The FPAR was working but the ID REQ went without response from the gateway. So at last I set the NODE ID manually and got it working. So I plugged in my gateway to the home assistant box again and got some errors with Python and looked in to my json-file storing all the sensors.

Node 3 which has been working for a long time has the following:

"type": 17,
        "sketch_name": "Pulsgivare El",
        "sketch_version": "1.1",
        "battery_level": 0,
        "protocol_version": "2.3.2",
        "heartbeat": 0

But the troublesome node, node 4, has the following data:


        "type": 17,
        "sketch_name": "MySensorNode",
        "sketch_version": "1.1",
        "battery_level": 0,
        "protocol_version": "2 /*!< Major release vers",
        "heartbeat": 0

So i started googling "Major release vers" and found this.. Another thing is that the gateway has created 20 nodes in total with no children at all.. I think that is unrelated.

My gateway is a regular SAMD21 from sparkfun running a modified gateway_serial example code.

I do think that the fault originates from the node because I could see the "2 /*!< Major release vers" when debugging the node and I thought it was strange but not sure if it had always been like that. Probably not.

I'm in the process of trying to fix this and will report back if I find out the cause.

niclas0219 avatar Jun 10 '20 18:06 niclas0219

Small update: This is how my node boots up:


MYSENSORS LOGO (looks good in console but didnt survive copy-paste)
 2 /*!< Major release version*/.3 /*!< Minor release version*/.2 /*!< Patch version*/

71 MCO:BGN:INIT NODE,CP=RLNNA---,FQ=8,REL=255,VER=2 /*!< Major release version*/.3 /*!< Minor release version*/.2 /*!< Pat120 TSM:INIT
124 TSF:WUR:MS=0
139 TSM:INIT:TSP OK
145 TSF:SID:OK,ID=4
151 TSM:FPAR
1660 ?TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
5160 TSF:MSG:READ,0-0-4,s=255,c=3,t=8,pt=1,l=1,sg=0:0
5177 TSF:MSG:FPAR OK,ID=0,D=1
5185 TSM:FPAR:OK
5189 TSM:ID
5193 TSM:ID:OK
5197 TSM:UPL
8060 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
11079 TSM:UPL
13942 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
16701 TSF:MSG:READ,0-0-4,s=255,c=3,t=25,pt=1,l=1,sg=0:1
16715 TSF:MSG:PONG RECV,HP=1
16723 TSM:UPL:OK
16728 TSM:READY:ID=4,PAR=0,DIS=1
19599 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
22351 TSF:MSG:READ,0-0-4,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
26535 TSF:MSG:SEND,4-4-0-0,s=255,c=0,t=17,pt=0,l=25,sg=0,ft=0,st=OK:2 /*!< Major release vers
33998 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0

Something is not right...

niclas0219 avatar Jun 10 '20 18:06 niclas0219

Final update: So this problem only occurs(for me at least) using the Arduino IDE 1.9 beta. The only reason I am using this beta version is that I got caught in the bug yesterday: https://github.com/arduino/Arduino/issues/10332

Compiling and uploading using my old Arduino IDE 1.8.12 everything is working fine.

So what is it that 1.9 beta does differently? No idea, and I don't really have the time to investigate further.

niclas0219 avatar Jun 10 '20 18:06 niclas0219

Great information @niclas0219, thanks for contributing.

@damianchojna do you remember which version of the Arduino IDE you used? Was it a 1.9 beta?

@niclas0219 one small clarification regarding "The FPAR was working but the ID REQ went without response from the gateway." A gateway will NEVER respond to an ID REQ by itself. The response must come from a controller (home assistant in your case). If the controller wasn't connected, there could not be a response.

mfalkvidd avatar Jun 10 '20 21:06 mfalkvidd

@mfalkvidd Wow.. Nice clarification! I was sure that the gateway had a list of nodes stored in EEPROM and was 100% in charge of assigning NODE IDs. I'll have to remember that in the future... and read some more..

niclas0219 avatar Jun 11 '20 05:06 niclas0219