Its not complicated, but I have little pieces of code all over the place. I will post the files below after a few comments/explanation.
1] HardwareSerial.h needs a new constructor, which is simply a dummy constructor. We need it because we need to create a HardwareSerial object in SoftwareSerial. I included both the HardwareSerial.h and .cpp files below.
2] SoftwareSerial has a function setHardwareSerial(). setHardwareSerial() is to be called in setup() of your arduino code as follows:
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(8,7);
void setup(){
mySerial.begin(57600);
Serial.begin(57600);
mySerial.setHardwareSerial(Serial);
}
3] SoftwareSerial has a function setTo(bool). It sets the _toCompp to either true of false depending on the variable you pass it.
4] in SoftwareSerial.begin, _toCompp is set to false
So what on earth is _toCompp?
5] if _toCompp is set to false, your program will behave as it usually does (i.e serial data from a device will be written to serial buffer).
6] If _toCompp is true, it will send the serial data from a device directly to the computer (virtually eliminating the need for Arduino's serial buffer)
7] If you want to modify the format of how you send the data to the computer, you can play around with SoftwareSerial.recv() by changing the following:
if (_toCompp == true)
hardware.print(d,HEX);
if (_toCompp == true)
hardware.print(" ");
See files below for HardwareSerial.h,.cpp and SoftwareSerial.h,.cpp
HardwareSerial.h and .cpp goes to arduino>hardware>arduino>cores>arduino>
SoftwareSerial.h and .cpp goes to arduino>libraries>SoftwareSerial (note that this is the new version of newSoftSerial and you will need the other 2 files that go along with this library... Google should give you access to these if necessary)
SoftwareSerial.h (3.82 KB)
SoftwareSerial.cpp (13.8 KB)
HardwareSerial.cpp (5.91 KB)
HardwareSerial.h (2.37 KB)