Pages: [1]   Go Down
Author Topic: Serial example does not compile  (Read 2207 times)
0 Members and 1 Guest are viewing this topic.
Doesburg
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.begin(57600);
  Serial.println("Goodnight moon!");

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

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Doesburg
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where can I find these messages?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where can I find these messages?
At the bottom of your post!
Logged

Doesburg
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Doesburg
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Doesburg
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!
Logged

Pages: [1]   Go Up
Jump to: