diff options
author | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-08-06 13:11:42 +0300 |
---|---|---|
committer | Serhii Kostiuk <serhii.o.kostiuk@globallogic.com> | 2020-08-06 13:22:34 +0300 |
commit | 96445eaa166dd8f4ba99014f5eea2c1146b9db80 (patch) | |
tree | b40d7cd34bafb5b088fa91eb4167553751b93277 /src | |
parent | c7f63212d7e6596975835f23150ef20aea3b7b96 (diff) | |
download | libmts-io-96445eaa166dd8f4ba99014f5eea2c1146b9db80.tar.gz libmts-io-96445eaa166dd8f4ba99014f5eea2c1146b9db80.tar.bz2 libmts-io-96445eaa166dd8f4ba99014f5eea2c1146b9db80.zip |
Quectel EG25-G Delta Radio Firmware Upgrade support - libmts-io implementation
Refactored MTS::IO::ICellularRadio::sendCommand. Moved response waiting code to the
MTS::IO::ICellularRadio::waitResponse function.
**Motivation**
In many places in the modern libmts-io implementation there are cases when we need to
wait for some response from the radio without executing or sending any commands.
Such places may wait for some URC messages, acknowledge strings during
data transmission and so on.
One way to handle such cases is to use `sendCommand` with `cmd` argument set to an empty
string. It generally works but according to POSIX:
"If count is zero and fd refers to a file other than a regular file, the results are
not specified."
The other way to handle such cases is to use `isNeedMoreData` callback of `sendCommand`
function to analyze all the data on the fly. But this approach may not work for data
transfers when `sendCommand` and its std::string argument may not be used to store binary
data with null characters within.
This commit moves the "wait for the radio to answer" part to the separate function
which allows reusablity of such a code.
Diffstat (limited to 'src')
-rw-r--r-- | src/MTS_IO_ICellularRadio.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/MTS_IO_ICellularRadio.cpp b/src/MTS_IO_ICellularRadio.cpp index 9dbfad1..69f731a 100644 --- a/src/MTS_IO_ICellularRadio.cpp +++ b/src/MTS_IO_ICellularRadio.cpp @@ -376,6 +376,10 @@ std::string MTS::IO::ICellularRadio::sendCommand(MTS::AutoPtr<MTS::IO::Connectio return ""; } + return waitResponse(apIo, isNeedMoreData, timeoutMillis); +} + +std::string MTS::IO::ICellularRadio::waitResponse(MTS::AutoPtr<MTS::IO::Connection>& apIo, MTS::IO::ICellularRadio::IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis) { bool done = false; const uint32_t capacity = 1024; char buffer[capacity]; |