Software serial Library



  • Hello,

    MySensors :API is compatible with the softwareserial Library?

    I have some errors when i compile my sketch:
    SoftwareSerial\SoftwareSerial.cpp.o: In function __vector_3': C:\temp\libraries\SoftwareSerial/SoftwareSerial.cpp:305: multiple definition of __vector_3'
    MySensors\MyGateway.cpp.o:/utility/PinChangeInt.h:563: first defined here
    SoftwareSerial\SoftwareSerial.cpp.o: In function __vector_4': C:\temp\libraries\SoftwareSerial/SoftwareSerial.cpp:312: multiple definition of __vector_4'
    MySensors\MyGateway.cpp.o:/utility/PinChangeInt.h:573: first defined here
    SoftwareSerial\SoftwareSerial.cpp.o: In function __vector_5': C:\temp\libraries\SoftwareSerial/SoftwareSerial.cpp:319: multiple definition of __vector_5'

    regards
    MySensors\MyGateway.cpp.o:/utility/PinChangeInt.h:583: first defined here



  • I get the same error when using the SoftwareSerial library. More specific, it is a known limitation that you cannot use SoftwareSerial.h and PinChangeInt.h together without altering one or another.

    Let me give you an example, I was in the same case as you are now, I wanted to use an RF ID reader (125 kHz - RDM6300) on a software serial pin, in my case was A2 (don't ask why, this was the only input pin that I have on an UNO, it is stuffed with keyboard, display, motor actuator for door opening, button for manual door opening, ringer button and NRF24 - this is my all in one entrance sensor 🙂 ). So, what you have to do:

    pin A2 is on Port C

    • you have to disable in the SoftwareSerial.h the other intrerupts, except the one associated to PortC, that would be - PCINT1 is for Port C :

    PCINT0 is for Port B
    PCINT2 is for Port D
    PCINT3 - it is not the case of 328P so you can leave it uncommented

    so in SoftwareSerial.h comment the following for PCINT0 and 2:

    #if defined(PCINT0_vect)
    ISR(PCINT0_vect)
    {
    ReceiveOnlySoftwareSerial::handle_interrupt();
    }
    #endif

    The other thing that you have to do now is to tell PinChangeInt.h that you use Port C for other purpose. To do this, in MyGateway.cpp, ahead of the #include "utility/PinChangeInt.h" you should include the following:

    #define NO_PORTC_PINCHANGES

    Save, upload, enjoy... And don't forget to modify back what you altered.

    This assumes that you don't use intrerupts on pins...


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 2
  • 5
  • 2
  • 10

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts