1.4 Error compiling with PinChangeInt.h library file



  • I ran into a problem with the way the MySensors library folder is laid out. I am trying to modify a sensor sketch to use the PinChangeInt library located in the MySensors\utility folder. I am working on using it in the SceneController example posted in this forum topic http://forum.mysensors.org/topic/256/scenecontroller/9, but seeing it with any sketch. When I include the PinChangeInt library into the sketch using:
    include "utility/PinChangeInt.h"
    I get a bunch of compiler errors showing there are multiple definitions and saying they are already being defined in MyGateway.cpp. But I am not including that in the sketch. The only other includes are:

    include <MySensor.h>
    include <SPI.h>

    I can get it to compile without errors if I move MyGateway.cpp & MyGateway.h out of the MySensors library folder.

    Is the Arduino IDE trying to include everything that is in the MySensors library folder when it compiles? I also tried it on CodeBender and the same thing happens.

    I've got another question about how the MySensor.sleep function works but I'll save that for a separate forum thread.


  • Admin

    Don't think you can use the libraries included in MySensors utility (due to the f**d up build system of the Arduino "IDE").

    Include it separately among your libraries. You'll find it here.
    https://code.google.com/p/arduino-pinchangeint/downloads/list



  • @hek
    Nope, just downloaded and installed PinChangeInt in the libraries separately and tried both including it in quotes and <>. I misread the error message originally, it looks like the compiler is looking at MyGateway.cpp while it is compiling my sketch and reporting the PinChangeInt functions are already defined in MY sketch.

    The original way I tried to include it:

    include "utility/PinChangeInt.h"
    MySensors\MyGateway.cpp.o: In function PCintPort::enable(PCintPort::PCintPin*, void (*)(), unsigned char)': /utility/PinChangeInt.h:366: multiple definition of PCintPort::enable(PCintPort::PCintPin*, void (*)(), unsigned char)'
    Battery_Powered_SceneController_Pin_Change.cpp.o:C:\Users\Paul\Documents\Arduino\MySensors\libraries\MySensors/utility/PinChangeInt.h:366: first defined here

    Using the separately installed PinChangeInt libarary:

    include "PinChangeInt.h" in my sketch:
    MySensors\MyGateway.cpp.o: In function PCintPort::enable(PCintPort::PCintPin*, void (*)(), unsigned char)': /utility/PinChangeInt.h:366: multiple definition of PCintPort::enable(PCintPort::PCintPin*, void (*)(), unsigned char)'
    Battery_Powered_SceneController_Pin_Change.cpp.o:C:\Users\Paul\Documents\Arduino\MySensors\libraries\PinChangeInt/PinChangeInt.h:366: first defined here

    Using either include, I can get it to compile without error if I removed MyGateway.cpp from the MySensors library folder.

    BTW, how do you wrap code fragments to display properly in the forums?


  • Admin

    I can only answer your second question.

    Get a code section by entering 4 spaces or a tab character first of each line in the code section.

    You can also surround section by 3 backquote characters ```



  • I tried everything I could think of, including switching from version 1.0.5 of the Arduino IDE to version 1.5.7. Still get the same results, a conflict between my sketch trying to define the PinChangeInt functions and them already being defined in MyGateway.cpp. So I turned on verbose logging in the compiler and see it is hitting every .cpp file in the MySensors library folder. So I decided to try something else, compiling one of the example sketches. Well, it looks like the compiler is including at least something from MyGateway.cpp in every sketch. Here is what I found:

    Compiled example sketch BatteryPoweredSensor -

    With MySensors library folder as distributed:
    Sketch uses 17,732 bytes (57%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 476 bytes (23%) of dynamic memory, leaving 1,572 bytes for local variables. Maximum is 2,048 bytes.

    Removing MyGateway.cpp from the MySensors library folder:
    Sketch uses 17,146 bytes (55%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 443 bytes (21%) of dynamic memory, leaving 1,605 bytes for local variables. Maximum is 2,048 bytes.

    Compiled example sketch BinarySwitchSensor -

    With MySensors library folder as distributed:
    Sketch uses 14,766 bytes (48%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 436 bytes (21%) of dynamic memory, leaving 1,612 bytes for local variables. Maximum is 2,048 bytes.

    Removing MyGateway.cpp from the library folder:
    Sketch uses 14,190 bytes (46%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 403 bytes (19%) of dynamic memory, leaving 1,645 bytes for local variables. Maximum is 2,048 bytes.

    So, the compiled sketch is using 586 bytes more storage and 33 bytes more dynamic memory when MyGateway.cpp is present in
    the MySensors library folder. Both sketches seem to run fine compiled without MyGateway.cpp.

    MyMQTT.cpp is a gateway for a different controller, right? That one has no effect on the size of the compile sketch whether it is present in the folder or not. So there is something strange about the way MyGateway.cpp is constructed, it puts something in the compiled sketch that doesn't seem to be needed but doesn't generate any compile errors if it not present.

    I see there is an update to 1.4 that has been released. I have not tried that yet. What is the recommended method for installing the update? Just download the full zip and overwrite all the files?


  • Admin

    Ok, will have to look at this later tonight. The Arduino IDE builder is not the best on the planet (understatement).



  • Im running into the same issue with the 1.6.1 IDE. Is there a workaround besides removing the MyGateway.cpp?



  • @clgary solution from @hek, try development branch 😛


Log in to reply
 

Suggested Topics

  • 33
  • 3
  • 2
  • 5
  • 2
  • 9

18
Online

11.2k
Users

11.1k
Topics

112.5k
Posts