Go Down

Topic: NewSoftSerial to Arduino 1.0 SoftwareSerial issues? (Read 4511 times) previous topic - next topic

FeersumEndjinn

Hi all,

I have a program that runs under arduino 0023 fine, using the NewSoftSerial library to talk to a Bluetooth serial module so that I can control my robot from my laptop. 

However, since moving to Arduino 1.0 the NewSoftSerial library has been integrated as the new 'SoftwareSerial' and I have compile issues when moving to SoftwareSerial:

Code: [Select]
In file included from Heimdall.cpp:2:
C:\Users\FeersumEndjinn\Desktop\Arduino\libraries\SoftwareSerial/SoftwareSerial.h:95: error: conflicting return type specified for 'virtual void SoftwareSerial::write(uint8_t)'
C:\Users\FeersumEndjinn\Desktop\Arduino\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'


I have removed any code from my program that doesn't talk to the serial device in order to make it easier to read, my apologies for length:

Code: [Select]
#include <icrmacros.h>
#include <SoftwareSerial.h>

char incomingByte = 0;
int laserPin = 12;

long cm;

boolean show_menu = true;

SoftwareSerial btSerial(3, 2);

void setup() {
  pinMode(laserPin, OUTPUT);
  digitalWrite(laserPin, HIGH);
  btSerial.begin(57600);
}


void loop() {
  if (show_menu == true)  {
    print_menu();
    show_menu = false;
  }
  if (btSerial.available()) {
    incomingByte = btSerial.read();
    btSerial.println(incomingByte);
    show_menu = true;
  }

  switch (incomingByte)  {
  case 112:  // p
    ping();
    incomingByte = 0;
    break;
  case 108:  // l
    laser();
    incomingByte = 0;
    break;
  }
}

void print_menu() {
  btSerial.println("*****************");
  btSerial.println("'p'  Ping");
  btSerial.println("'l'  Laser");
  btSerial.print("Please enter choice: ");
  show_menu = false;
}

void laser() {
  if (laserPin = HIGH) {
    digitalWrite(laserPin, LOW);
    btSerial.println("Laser On");
  }  else if (laserPin = LOW)
// ...
}

void ping() {
  btSerial.println("");
  btSerial.print("Ping Distance: ");
  btSerial.print(cm);
  btSerial.println("cm");
  btSerial.println("");
  delay(100);
}


I use 4 methods from the SoftwareSerial library - all basic.

mySerial.read
mySerial.available
mySerial.print
mySerial.println

All of these are fairly standard so I can't understand why I am having such an issue?

Regards,
FeersumEndjinn

PaulS

Code: [Select]
#include <SoftwareSerial.h>

char inChar = 0;

SoftwareSerial btSerial(3, 2);

void setup()
{
  btSerial.begin(57600);
  btSerial.print("Hey there!");
  btSerial.println("Arduino calling...");
}

void loop()
{
  while(btSerial.available() > 0)
  {
    inChar = btSerial.read();
  }
}

Compiles with no errors for me. Does it compile for you?

FeersumEndjinn

Nope, I get a compile error :S

Code: [Select]
In file included from sketch_dec12c.cpp:1:
C:\Users\ian.havelock\Desktop\Arduino\libraries\SoftwareSerial/SoftwareSerial.h:95: error: conflicting return type specified for 'virtual void SoftwareSerial::write(uint8_t)'
C:\Users\ian.havelock\Desktop\Arduino\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'


Very strange!

James C4S

Paul's code compiles for me as well.


Nope, I get a compile error


Just a thought... Do you have have an old serial library in your libraries folder?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

FeersumEndjinn

No I don't - I downloaded Arduino 1.0 and extracted the folder to my desktop - it isn't installed and the libraries folder is intact and hasn't been modified since download.

I have a seperate folder called arduino-0023 and inside the libraries folder there, there is a NewSoftSerial library.

I've just deleted and re-downloaded the the Arduino 1.0 software, extracted it to a different location and copy/pasting the code above into a new sketch compiled!  Very very strange, maybe a bad download or something but many thanks for the help.

Regards,
FeersumEndjinn

James C4S

Actually referring to the libraries folder where your sketches are stored. That's where "user" libraries should go while "built-in" libraries go in the Aruino folder.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Ae7flux

I just solved the same problem. It seems that since all versions of Arduino write to the same preferences.txt file if you run an older version you must delete this file before running version 1.0 (and after closing the old version) or you will get all sorts of unexpected behaviour.

Ae7flux

Or maybe not! It looks like SoftwareSerial is incompatible with the Atmega8 I was using.

PaulS

Quote
It looks like SoftwareSerial is incompatible with the Atmega8 I was using.

Nice of you to mention that you were not using an Arduino at the beginning.

aticio

Hi there.

Does anybody have a solution for this problem?

I also got it and tried to install Arduino 1.0 on two PCs.
But on both i got the same errors as described above.

Thanks a lot and kind Regards!

Aticio

retrolefty


Quote
It looks like SoftwareSerial is incompatible with the Atmega8 I was using.

Nice of you to mention that you were not using an Arduino at the beginning.


Well the IDE 1.0 still shows support for a mega8 (Arduino NG board) as the last board choice?


Willy

Hi,
with the Arduino 22 and NewSoftSerial Test from Mikal Hart.
I received from GPS Receiver the following information:
Goodnight moon!
$GPZDA,152444.00,14,12,2011,,*60
$GPGLL,4730.3739,N,00924.9473,E,152444.00,A,A*63
$GPZDA,152446.00,14,12,2011,,*62
$GPGLL,4730.3739,N,00924.9473,E,152446.00,A,A*61

with the new Arduino1.0 and SoftwareSerial Library Example
I lose characters by the $GPGLL sentence ???
Goodnight moon!
$GPZDA,152656.00,14,12,2011,,*61                           
$GPGLL,4730.3737,N,00924.9468,E,152656.00A$GPZDA,152658.00,14,12,2011,,*6F
$GPGLL,4730.3737,N,00924.9467,E,152658.00*$GPZDA,152700.00,14,12,2011,,*63
                                                                ¦ missing comma , A,A 63 and "CR" "LF"             
Can someone help my ? I receive all 2 second first the $GPZDA after the $GPGLL sentence.               
Willy

Go Up