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?
-
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 errorconst 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 };
-
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!
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
MYSController with MQTT Gateway (via Node Red)
Development • 11 Aug 2024, 22:35 • slt1 11 Aug 2024, 22:35 -
Gateways
Development • 6 Feb 2024, 01:16 • OldSurferDude 6 Feb 2024, 14:22 -
(SOLVED) Sensebender Gateway and HomeAssistant: where does the battery level come from?
Development • 6 Jan 2024, 19:27 • pikim 6 Jan 2024, 19:27 -
[mysensors] Not a valid message: invalid literal for int() with base 10: '\x00\x000'
Development • 18 Sept 2024, 20:34 • kiesel 20 Sept 2024, 08:28 -
MQTT GW on ESP8266 supporting SSL/TLS?
Development • 4 Jun 2024, 10:21 • bgunnarb 27 Jun 2024, 13:53