arduino / ArduinoCore-avr

The Official Arduino AVR core
https://www.arduino.cc
1.23k stars 1.05k forks source link

SoftwareSerial and Official Arduino Robot #185

Open MikaylaFischler opened 10 years ago

MikaylaFischler commented 10 years ago

When using SoftwareSerial with the Arduino Robot with arduino 1.0.5 (and in 1.5.5, but different file paths), this happens:

C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:399: error: 'digitalPinToPCICR' was not declared in this scope
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:401: error: 'digitalPinToPCICRbit' was not declared in this scope
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: 'digitalPinToPCMSK' was not declared in this scope
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: 'digitalPinToPCMSKbit' was not declared in this scope
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: 'digitalPinToPCMSK' was not declared in this scope
C:\Program Files\Arduino\arduino-1.0.5\libraries\SoftwareSerial\SoftwareSerial.cpp:418: error: 'digitalPinToPCMSKbit' was not declared in this scope
ghost commented 10 years ago

I'm having the same problem now. Could you solve this?

xaljox commented 10 years ago

I've added a constructor in the USBAPI.h file, to initialise the variable. class Serial_ : public Stream { private: int peekbuffer; // Removed = -1 public: Serial() { peek_buffer = -1; } // Constructor added void begin(unsigned long); void begin(unsigned long, uint8_t); void end(void);

I once tried to do changes on another Github project, but never succeeded to do so. I'm working with eclipse with the arduino plugin (http://www.baeyens.it/eclipse/), with that IDE it is very easy to edit the file directly. I guess it is harder in the original arduino IDE to go to the file and fix it, just find the file on your system and edit it, with an external editor.

JImmy Venema

On 19 Jun 2014, at 13:23, Ahmet Yakar notifications@github.com wrote:

I'm having the same problem now. Could you solve this?

— Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

I think there is an conflict. I had the same problem with the Wire library. When I compile the codes, I move the Wire folder from libraries folder to somewhere else. I think Robot library already has the softserial library. Try in this way. I hope it will work.

ghost commented 6 years ago

Ok I'm playing with this now, and still seems to be an issue.

facchinm commented 6 years ago

Hi @lukzmu , could you expand on that? Can you paste your configuration (IDE version, OS) and the verbose output of the compilation (and an example sketch too maybe) ? Thanks!

ghost commented 6 years ago

@facchinm Sorry for the long wait for a reply :)

Arduino IDE: 1.8.5 OS: Ubuntu 64-bit

This is what I'm getting when I try to add the Software serial to my code:

Arduino: 1.8.5 (Linux), Board: "Arduino Robot Control"

/home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
/home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:319:36: error: 'digitalPinToPCICR' was not declared in this scope
   if (digitalPinToPCICR(_receivePin)) {

                                    ^
In file included from /home/lukzmu/Downloads/arduino-1.8.5/hardware/tools/avr/avr/include/avr/io.h:99:0,
                 from /home/lukzmu/Downloads/arduino-1.8.5/hardware/tools/avr/avr/include/avr/interrupt.h:38,
                 from /home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:41:
/home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:360:76: error: 'digitalPinToPCICRbit' was not declared in this scope
     *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));

                                                                            ^
/home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:363:51: error: 'digitalPinToPCMSK' was not declared in this scope
     _pcint_maskreg = digitalPinToPCMSK(_receivePin);

                                                   ^
In file included from /home/lukzmu/Downloads/arduino-1.8.5/hardware/tools/avr/avr/include/avr/io.h:99:0,
                 from /home/lukzmu/Downloads/arduino-1.8.5/hardware/tools/avr/avr/include/avr/interrupt.h:38,
                 from /home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:41:
/home/lukzmu/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp:364:60: error: 'digitalPinToPCMSKbit' was not declared in this scope
     _pcint_maskvalue = _BV(digitalPinToPCMSKbit(_receivePin));

                                                            ^
exit status 1
Error compiling for board Arduino Robot Control.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And here is the actual code:

#include <ArduinoRobot.h>
#include <SoftwareSerial.h>

int tx = D3;
int rx = D4;

SoftwareSerial sSerial(rx, tx);

void setup() {
  // put your setup code here, to run once:
  Robot.begin();
  sSerial.begin(4800);
}

void loop() {
  // put your main code here, to run repeatedly:

}
facchinm commented 6 years ago

This happens because Robot Control variant does not contain all the needed macros that you can normally find in all Leonardo-derived boards (see https://github.com/arduino/ArduinoCore-avr/blob/master/variants/leonardo/pins_arduino.h#L149). The latest commit touching that lines is https://github.com/arduino/ArduinoCore-avr/commit/3e68702149cbf938f11bc9410eb7f9a0c811fa28 so it should be almost safe to backport it to RobotControl after taking a look ad the different pinmappings. If anyone is interested in this task, we'll be glad to review and eventually merge it :wink:

JaroslavMalik commented 5 years ago

use AltSoftSerial