Arduino Due Serial Ports

Hi,

I’m trying to set up a Sparkfun Tsunami Super WAV Trigger board with my Arudino Due. When I include the library (#include <Tsunami.h>) and attempt to compile, I get an error:

In file included from /Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:11:0:
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::start()':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:21:4: note: in expansion of macro 'TsunamiSerial'
    TsunamiSerial.begin(57600);
    ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::flush()':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:52:8: note: in expansion of macro 'TsunamiSerial'
  while(TsunamiSerial.available())
        ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::update()':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:66:9: note: in expansion of macro 'TsunamiSerial'
  while (TsunamiSerial.available() > 0) {
         ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::masterGain(int, int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:193:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 8);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::setReporting(bool)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:207:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 6);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::trackControl(int, int, int, int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:310:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 10);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::stopAllTracks()':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:323:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 5);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::resumeAllInSync()':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:336:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 5);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::trackGain(int, int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:355:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 9);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::trackFade(int, int, int, bool)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:377:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 12);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::samplerateOffset(int, int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:397:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 8);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::setTriggerBank(int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:411:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 6);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::setInputMix(int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:425:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 6);
  ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp: In member function 'void Tsunami::setMidiBank(int)':
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.h:73:23: error: 'Serial1' was not declared in this scope
 #define TsunamiSerial Serial1
                       ^
/Users/jared/Documents/Arduino/libraries/Tsunami-Arduino-Serial-Library-master/Tsunami.cpp:439:2: note: in expansion of macro 'TsunamiSerial'
  TsunamiSerial.write(txbuf, 6);
  ^
exit status 1
Error compiling for board Arduino Due (Programming Port).

I have tried tried changing the specific serial port in Tsunami.h (e.g. Serial, Serial1, Serial2, Serial3) and I get the samer error. I’m certain I have selected the board “Arduino Due (Programming Port)”, and I’m using the correct port to program (although this never gets past the compile stage).

I have tried to use the serial ports in a regular sketch with this setup, and they all work as expected. The issue seems to be something to do with referencing Serial in a library. Any tips/advice would be greatly appreciated!

OS: MacOS 10.15.2
Arduino: Version 1.8.11
Arduino SAM Boards: Version 1.6.12
Tsunami Library: https://github.com/robertsonics/Tsunami-Arduino-Serial-Library

The problem is the library assumes Serial1 is always declared in the core library’s HardwareSerial.h. That’s where it’s done for the AVR Boards (e.g., Leonardo, Mega), but it’s not done in that file for the Due. Instead, it’s done in variant.h. Probably the best fix to make it work for all boards is to change line 71 Tsunami.h from:

#include <HardwareSerial.h>

to:

#include <Arduino.h>

That worked perfectly! Thanks pert.

You're welcome. I'm glad to hear it's working now. Enjoy! Per