Reduce iRAM usage for plugins using SoftwareSerial (#631)

* [addLib] Added SoftwareSerial library

Added latest version from: https://github.com/plerup/espsoftwareserial

* [renLib] Renamed files to avoid conflicts with existing code

* [renLib] Changed include according to rename

* [renLib] Renamed all occurences and includes and removed unused pins

Renamed to make sure all plugins use the 'new' ESPeasySoftwareSerial.
Also added pinToIndex function to reduce memory footprint with about 150 Bytes, as described in issue #630

* [unused pins] Adjust indices in object list

Forgot to change the indices in the object list of SoftwareSerial

* Simple patch for timeouts

As mentioned in this issue: https://github.com/plerup/espsoftwareserial/issues/54

* [SoftSerial] Set ObjList static

Set the object list static to share all SoftwareSerial iRAM used as described in #630

* [revertLib] Revert to old version lib, since new version uses more iram

Just to test with old version, originally available in 2.3.0 library, to see if memory usage improves.

* [test] Reduce number of ports to 1 and lower buffer size to 18 for MHZ19

Just as a test, to see what happens to the iRAM usage, lower the number of concurrent softserial ports to 1.
Also the default buffer size = 64 Bytes. The MH-Z19 sensor can do with less, since a response will be up to 9 bytes, a 18-byte buffer allows for 2 messages to be stored.

* Enable usage of up to 10 concurrent softserial and reduce variable sizes

Re-enable use of up to 10 concurrent software serials.
Also reduce the variable sizes to smaller ranges. (e.g. uint8 instead of int)

* [test] Limit number of concurrent software serial devices

Earlier tests show the amount of iRAM used is somewhat related to the maximum number of allowed software serial ports.
In this test it is set to 3 and they are assigned through first come first served a slot.
This commit is contained in:
Gijs Noorlander
2017-12-18 22:02:53 +01:00
committed by DatuX
parent cd01283ac6
commit c71a43c3a6
14 changed files with 435 additions and 23 deletions
+7 -7
View File
@@ -26,7 +26,7 @@
#include <SensorSerial.h>
SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) : SoftwareSerial(receivePin, transmitPin, inverse_logic, buffSize)
SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) : ESPeasySoftwareSerial(receivePin, transmitPin, inverse_logic, buffSize)
{
//boolean sws = isValidGPIOpin(receivePin);
_hw = receivePin < 0;
@@ -37,7 +37,7 @@ void SensorSerial::begin(long speed)
if (_hw)
Serial.begin(speed);
else
SoftwareSerial::begin(speed);
ESPeasySoftwareSerial::begin(speed);
}
int SensorSerial::peek()
@@ -45,7 +45,7 @@ int SensorSerial::peek()
if (_hw)
return Serial.peek();
else
return SoftwareSerial::peek();
return ESPeasySoftwareSerial::peek();
}
size_t SensorSerial::write(uint8_t byte)
@@ -53,7 +53,7 @@ size_t SensorSerial::write(uint8_t byte)
if (_hw)
return Serial.write(byte);
else
return SoftwareSerial::write(byte);
return ESPeasySoftwareSerial::write(byte);
}
int SensorSerial::read()
@@ -61,7 +61,7 @@ int SensorSerial::read()
if (_hw)
return Serial.read();
else
return SoftwareSerial::read();
return ESPeasySoftwareSerial::read();
}
int SensorSerial::available()
@@ -69,7 +69,7 @@ int SensorSerial::available()
if (_hw)
return Serial.available();
else
return SoftwareSerial::available();
return ESPeasySoftwareSerial::available();
}
void SensorSerial::flush()
@@ -77,5 +77,5 @@ void SensorSerial::flush()
if (_hw)
Serial.flush();
else
SoftwareSerial::flush();
ESPeasySoftwareSerial::flush();
}