Vs2015+Visual Micro + MySensors



  • Hi,
    I've tried to migrate from the arduino IDE to the VS2015 Community+Visual Micro support for Arduino.
    When attempting to compile a sketch with MyMessage and receive handler I get an error "BatteryPoweredWaterLeakSensor.ino:39:20: error: 'MyMessage' does not name a type"

    When excluding the define of MyMessage and the receive handler there is no problem and project compile with no errors:

    void receive(const MyMessage &message) {
    
    }
    

    Compiling the same sketch with the Arduino IDE or when removing the MyMessage usage I get no errors.

    Any idea?


  • Mod

    Do the vanilla examples work? (like https://github.com/mysensors/MySensors/blob/master/examples/DimmableLight/DimmableLight.ino )

    You'll probably get the same error but it might be worth checking.



  • OK,
    I was able to find the RCA.
    Apparently, the issue was related to the location of the #include and the const variables.
    The following code generates error

    const int SENSOR_ANALOG_PINS[] = { A0, A1 }; 
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define CHILD_ID_SENSOR		0
    #define CHILD_ID_VOLTAGE	1
    
    
    MyMessage msgTripped(CHILD_ID_SENSOR, V_TRIPPED);
    MyMessage msgVoltage(CHILD_ID_VOLTAGE, V_VOLTAGE);
    
    

    The following code is GOOD. Hence, the const values has to be defined post the header include

    #include <SPI.h>
    #include <MySensors.h>
    
    #define CHILD_ID_SENSOR		0
    #define CHILD_ID_VOLTAGE	1
    
    
    MyMessage msgTripped(CHILD_ID_SENSOR, V_TRIPPED);
    MyMessage msgVoltage(CHILD_ID_VOLTAGE, V_VOLTAGE);
    
    const int SENSOR_ANALOG_PINS[] = { A0, A1 }; 
    

  • Mod

    Strange. To my knowledge, that shouldn't matter. But great that you found a solution.



  • I can absolutely confirm this with VS2015, Visual Micro and MySensors 2.1.1. This is clearly a kind of merging, that is done by Visual Micro.

    All includes have to be made BEFORE the first line of code is executed. The initialization of your SENSOR_ANALOG_PINS array is such a line of code.

    Just posting it to keep it visible and well-scored at search engines, as this is SOLVED and works fine. Thank you!


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.