From 96445eaa166dd8f4ba99014f5eea2c1146b9db80 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 6 Aug 2020 13:11:42 +0300 Subject: 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. --- include/mts/MTS_IO_ICellularRadio.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 085c217..e4456cc 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -83,6 +83,12 @@ namespace MTS { const std::vector& vBail = DEFAULT_BAIL_STRINGS, int32_t timeoutMillis = 100, const char& ESC = CR); + + //! Wait for response from the radio without sending any data to it + static std::string waitResponse(MTS::AutoPtr& apIo, + IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100); + static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); static std::string extractModelFromResult(const std::string& sResult); static std::string getCodeAsString(CODE code); -- cgit v1.2.3