Closed vortigont closed 2 years ago
Hey @vortigont , I finally found some time for closing all the old PRs, including #31 and now noticed that you have also provided a similar fix here. I will therefore not be merging your Constructor overload however I could cherry pick your Fix for the compiler warning.
In the new update, I cherry picked your change, However there is now a different error showing up.
PZEM004Tv30.cpp: In destructor 'PZEM004Tv30::~PZEM004Tv30()':
PZEM004Tv30.cpp:142:9: warning: deleting object of polymorphic class type 'SoftwareSerial' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
142 | delete this->localSWserial;
So this hasn't really improved the situation. As I have already suggested, the best thing would be to move away from local SoftwareSerial instance and instead require one to be passed as reference during the initialization. This way, we don't have to handle any destruction.
Closes #20
Signed-off-by: Emil Muratov gpm@hotplug.ru