stdevPavelmc / ft817

Improved Arduino CAT library for the Yaesu FT817
15 stars 4 forks source link

ESP32 board - SoftwareSerial #4

Open dl5dla opened 3 years ago

dl5dla commented 3 years ago

Hi Pavel, the code does not successfully compile for ESP32 board. Error message is

src/main.cpp:14:28: fatal error: SoftwareSerial.h: No such file or directory

It looks like that SoftwareSerial is not supported out of the box for ESP32 boards. May be there are some special libraries for SoftwareSerial on ESP32, but nevertheless it might be more efficient to use one of the three available UARTs (UART0, UART1 and UART2) of the ESP32. I am wondering how to adapt the code accordingly but I am not sure (and may be not skilled enough) to start.

stdevPavelmc commented 3 years ago

Thanks for the bug report and the idea, it can be extended to the ESP8266 I think...

I will take a peek on it on the weekend.

Thanks

dl5dla commented 3 years ago

I made some quick and dirty changes to support UART2 of the ESP32. Code needs to be cleaned up.

in ft817.h:

line 286:

define HAVE_ESP 1

include

ifndef HAVE_ESP

#include <SoftwareSerial.h>

endif

line 335:

class FT817 { public: FT817(); // setup

ifdef HAVE_ESP

      void begin(int baud,int handshake,int rx,int tx);
    #else
      void setSerial(SoftwareSerial portInfo);  // load the softserial into the FT817
      void begin(int baud);                     // set the baudrate of the softserial lib 
    #endif
    // toggles

in ft817.cpp:

line 29:

include "ft817.h"

ifdef HAVE_ESP

include

HardwareSerial rigCat(2);

else

#include <SoftwareSerial.h>
extern SoftwareSerial rigCat(12, 11); // rx,tx

endif

define dlyTime 5 // delay (in ms) after serial writes

FT817::FT817(){ } // nothing to do when first instanced

/** SETUP ****/

ifndef HAVE_ESP

// Setup software serial with user defined input // from the Arduino sketch (function, though very slow) void FT817::setSerial(SoftwareSerial portInfo) { rigCat = portInfo; // just commented out for ESP - no idea how to adapt for ESP }

endif

// similar to Serial.begin(baud); command

ifdef HAVE_ESP

void FT817::begin(int baud,int handshake,int rx,int tx) { rigCat.begin(baud,handshake,rx,tx); }

else

void FT817::begin(int baud) { rigCat.begin(baud); }

endif

in main.cpp:

line 14:

include "ft817.h"

ifndef HAVE_ESP

#include <SoftwareSerial.h>

endif

line 29:

void setup() { Serial.begin(9600,SERIAL_8N1,12,13);

ifdef HAVE_ESP

radio.begin(9600,SERIAL_8N1,22,23);
#else 
radio.begin(9600);
#endif

Serial.println("Starting...");

}

stdevPavelmc commented 2 years ago

Sorry for the long delay...

I will be playing with this this weekend and will try to simulate here an fixing.