Well, yes and no (I think). Yes hardwareserial.cpp IS still being compiled - I tested that by temporarily adding a statement:
“#error Hardwareserial is here” to hardwareserial.cpp and it does show the error.
However I’m not sure its being linked.
I reached that conclusion by doing the following:
I wrote a simple sketch as follows:
void setup()
{
pinMode(13, OUTPUT);
digitalWrite(13,HIGH);
}
void loop(){}
That sketch took 846 bytes.
Then I added Serial.begin(57600); to setup().
The program size changed to 1594 bytes.
Then I made copies of hardwareserial.cpp and hardwareserial.h which I renamed to lkhardwareserial.cpp and lkhardwareserial.h. I modified them (work in process) with an eye to adding support for all frame sizes, startbits, parity etc. (probably using other version(s) of begin(). I also renamed the class, buffers, and buffer struct. I did NOT however rename the instantiated object(s) - Serial, Serial1, etc.
I also added another file “options.h” with the following contents:
#ifndef OPTIONS_H
#define OPTIONS_H
#define NOHARDWARESERIAL
#ifdef NOHARDWARESERIAL
#define LKHWSERIAL
#endif
#endif
WProgram.h was changed per my previous post;
#ifdef __cplusplus
#ifndef NOHARDWARESERIAL //addedLJK
#include “HardwareSerial.h”
#endif //addedLJK
Finally I changed the sketch pde to look like this:
#include “options.h”
#include “lkhardwareserial.h”
void setup()
{
pinMode(13, OUTPUT);
digitalWrite(13,HIGH);
Serial.begin(57600);
}
void loop(){}
This version’s program size is 1670 bytes - just 76 bytes larger than the one which used hardwareserial - about right considering the additions I made.
Further I tested which version of Serial was really running by changing (temporarily) the ISR to store the received character followed by a ‘_’ character in my version. I added Serial.read() and Serial.print() statements in loop(). It clearly shows that my version is the one actually executing.
Personally I wish that hardwareserial had to be explicitly declared in sketches by including the header file and instancing an object in the user code. The constructor could easily have been written to take the various flavors of chips into account requiring only the baud rate and perhaps number of bits, stop bits, and parity to be declared when instancing the Serial object. begin() would simply enable receive and transmit. I understand, however, the thinking behind the way it is now - a bit simpler for inexperienced users.