yeganemehr / arduino-at Goto Github PK
View Code? Open in Web Editor NEWIt's a fully async library for communicate with AT modems.
License: MIT License
It's a fully async library for communicate with AT modems.
License: MIT License
bool ATConnection::parseNotification() noexcept
{
auto pos = buffer.indexOf('\n');
if (pos < 0)
{
return false;
}
ATNotificationEvent event(buffer.substring(0, pos - 1));
this->emit(&event);
buffer.remove(0, pos + 1);
return true;
}
buffer.substring is a temporary object and the reference to it is lost.
The panic define does not exists in ESP32 environment. Thanks for following the project.
In file included from src/main.cpp:3:
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp: In member function 'bool ATConnection::parse()':
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp:111:4: error: 'panic' was not declared in this scope
panic();
^~~~~
In file included from .pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.cpp:1:
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp: In member function 'bool ATConnection::parse()':
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp:111:4: error: 'panic' was not declared in this scope
panic();
^~~~~
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.cpp: In member function 'void ATConnection::putTheCommandInBuffer(ExecuteCommand*)':
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.cpp:80:2: error: 'panic' was not declared in this scope
panic();
^~~~~
In file included from .pio/libdeps/wemos_d1_mini32/arduino-sim800/src/Sim800.hpp:4,
from .pio/libdeps/wemos_d1_mini32/arduino-sim800/src/Sim800.cpp:1:
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp: In member function 'bool ATConnection::parse()':
.pio/libdeps/wemos_d1_mini32/arduino-at/src/ATConnection.hpp:111:4: error: 'panic' was not declared in this scope
panic();
^~~~~
Hello @yeganemehr
in ATConnection.cpp line 72, the pointer command->secondpart is freed and set to nullptr.
delete[] command->secondPart;
command->secondPart = nullptr;
As it is a copy, the pointer is not set to nullptr in the commandQueue
This copy is done here (ATConnection.cpp line 237)
auto item = commandQueue.front();
In some cases (f.i. when sending sms text with several \r\n) the answer of the sim800 may include several '>' and the delete[] is called for each '>' and crashes the code at the second call (already freed).
I fixed it by changing the line 237 with
CommandQueueItem *item = &commandQueue.front();
and using the pointer instead of the union in the next lines
Then the commandQueue is changed and the secondPart is set to nullPtr
and testing the command.execute.secondPart value before calling putTheCommandInBuffer
// assert(item->command.execute.secondPart);
buffer.clear();
if (item->command.execute.secondPart) {
putTheCommandInBuffer(&item->command.execute);
}
Thanks for your attention.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.