Motor Shield Lib and SoftwareSerial

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
solderspot
 
Posts: 5
Joined: Thu Dec 26, 2013 4:33 pm

Motor Shield Lib and SoftwareSerial

Post by solderspot »

It seems the SoftwareSerial library is being used by the Motor Shield lib. Is this true? I only see a reference to the Wire lib in the code and as far as I can tell the Wire lib does not use SoftwareSerial.

I have my own pin interrupt vector but compiling with the motor shield lib gets me the following link error:

Code: Select all

SoftwareSerial/SoftwareSerial.cpp.o: In function `__vector_5':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:319: multiple definition of `__vector_5'
NavBot_v1.cpp.o:BlackBot.h:215: first defined here
Surprisingly googling this problem doesn't turn up anything. Maybe this is some issue with my instance of the Arduino IDE?

solderspot
 
Posts: 5
Joined: Thu Dec 26, 2013 4:33 pm

Re: Motor Shield Lib and SoftwareSerial

Post by solderspot »

Never mind. The problem is related to how the Arduino IDE builds sketches. It seems that it parses the main sketch for #include<> statements and assumes the library is being used. In my case I had conditionally compiled sections but they are ignored when parsing for the #includes.

My only work-around I can see is to comment and uncomment code as needed. Bah!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Motor Shield Lib and SoftwareSerial

Post by adafruit_support_rick »

But how does SoftwareSerial.h enter the picture?

solderspot
 
Posts: 5
Joined: Thu Dec 26, 2013 4:33 pm

Re: Motor Shield Lib and SoftwareSerial

Post by solderspot »

I have a sketch that I conditionally compile for multiple robots. Each both has different hardware setups and one of them uses SoftwareSerial so I have #include <SoftwareSerial.h> in the sketch but technically it is compiled out at the preprocessor stage, i.e. #if BIG_BOT ... #endif. However, it seems that when the Arduino IDE is checking for which libraries to pull in, it does not evaluate the conditionals... it assumes all the header files are being referenced.

You can see better what I'm doing if you look at Set 3 in this post: http://wp.me/p493sy-jy

What I'm doing is kinda hacky anyway but it's the simplest way I can think off to test my code on multiple hardware configs within the Arduino IDE.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Motor Shield Lib and SoftwareSerial

Post by adafruit_support_rick »

Well, that's good to know about the includes. I always had the feeling that Arduino did something weird with include files, so I guess I'm not entirely surprised.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”