Go Down

Topic: Serial example does not compile (Read 2499 times) previous topic - next topic


This example from the Arduino website returns following error.
  Software serial multple serial test

Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.

The circuit:
* RX is digital pin 2 (connect to TX of other device)
* TX is digital pin 3 (connect to RX of other device)

created back in the mists of time
by Tom Igoe
based on Mikal Hart's example

This example code is in the public domain.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup() 
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.println("Hello, world?");

void loop() // run over and over
  if (mySerial.available())
  if (Serial.available())

Here the error:

In file included from test_serial.cpp:18:
/Users/gbosch/Documents/Arduino/libraries/SoftwareSerial/SoftwareSerial.h:95: error: conflicting return type specified for 'virtual void SoftwareSerial::write(uint8_t)'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'

What to do?


What to do?

Spend some time reading the messages. They tell you exactly what the problem is. If needed, spend some time searching for those errors which have posted far too many times this year.


Where can I find these messages?


Where can I find these messages?

At the bottom of your post!


Ok, Paul. You are right. Well I did. But I don't see the conflict and how to solve it. The error refers to line 18 in my code, saying #include <SoftwareSerial.h>, telling me that the problem is between system libraries SoftwareSerial and Print. Should I change them? I have no idea how to go on with this. Hope you can help.
I would appreciate if the reference section of the Arduino website was more informative.


What version of the IDE are you using?

Why do you have a SoftwareSerial library in your libraries folder? The SoftwareSerial library has always been part of the Arduino core.


Since I'm using 1.0-rc2 I experience a lot of similar problems. So far I could tackle them.
While porting a Arduino_22 sketch to 1.0 I ran into this problem, and found out that even examples bundled with Arduino 1.0 have the same problem, so these code examples don't give any support on this.

Ok, my original sketch used NewSoftSerial. This library is still in my libraries folder. NewSoftSerial website says: To port your code to 1.0, simply change all NewSoftSerial references to SoftwareSerial. Which I did. Result, see above.
With Arduino_23 the sketch compiles with no problem. Any ideas?


Why do you have a SoftwareSerial library in your libraries folder?

Paul, thanks for your hint. I overlooked there was a 'stray' library in my folder. Removed it and that solved the problem!

Go Up