From 1afb3c7bb338eba0410f85be8e5eaf192a7c4857 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Tue, 4 Aug 2020 10:20:54 +0300 Subject: Quectel EG25-G Delta Radio Firmware Upgrade support - libmts-io implementation During testing with L4G1 device I discovered some inconsistencies in behaviour between EG25-G device and EG95 devices (EG95-NA and EG95-E). EG25-G device that I have on hands does not allow to perform downgrades using delta images. When there is an attempt to apply a downgrade delta image it behaves as the following: - radio prints `OK` - radio prints `+QIND: "FOTA",502` - radio is not rebooted While EG95 radios always reboot at least once to apply the firmware image. Even if it is not valid. Also I noticed that detach from the serial bus may take more than 10 seconds in some rare cases. Thus we need to wait not a fixed amount of time but until the radio actually detaches from the bus. This commit attempts to address the findings described above. --- include/mts/MTS_IO_QuectelRadio.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 58e3d25..0f24db8 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -86,6 +86,9 @@ namespace MTS { CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); CODE fumoWaitNewFirmware(UpdateCb& stepCb); + /// Parse error code in early FUMO URC result received before the first attempt to flash the firmware + std::string getFumoEarlyErrorCode(const std::string& sRadioInput); + /// Get value from container by its index, use default value if not found. Non-template version. const std::string& getByIndex(const std::vector& vector, size_t index, const std::string& defaultValue) { if (index >= vector.size()) { -- cgit v1.2.3 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 From e1855057708468bc5383d948be70da7179730231 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 6 Aug 2020 14:06:19 +0300 Subject: Quectel EG25-G Delta Radio Firmware Upgrade support - libmts-io implementation Added waitResponse overloads to the public interface of ICellularRadio. --- include/mts/MTS_IO_CellularRadio.h | 7 +++++++ include/mts/MTS_IO_ICellularRadio.h | 11 +++++++++++ 2 files changed, 18 insertions(+) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index ab6e00a..2b03d8f 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -126,6 +126,13 @@ namespace MTS { int32_t timeoutMillis = 100, const char& ESC = ICellularRadio::CR) override; + //! Wait for response from the radio without sending any data to it + virtual std::string waitResponse(const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100) override; + + //! Wait for response from the radio without sending any data to it + virtual std::string waitResponse(IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100) override; protected: diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index e4456cc..61ffd20 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -88,6 +88,9 @@ namespace MTS { static std::string waitResponse(MTS::AutoPtr& apIo, IsNeedMoreData& isNeedMoreData, int32_t timeoutMillis = 100); + static std::string waitResponse(MTS::AutoPtr& apIo, + const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100); static CODE test(MTS::AutoPtr& apIo, uint32_t timeoutSeconds = 30); static std::string extractModelFromResult(const std::string& sResult); @@ -551,6 +554,14 @@ namespace MTS { int32_t timeoutMillis = 100, const char& ESC = CR) = 0; + //! Wait for response from the radio without sending any data to it + virtual std::string waitResponse(const std::vector& vBail = DEFAULT_BAIL_STRINGS, + int32_t timeoutMillis = 100) = 0; + + //! Wait for response from the radio without sending any data to it + virtual std::string waitResponse(IsNeedMoreData& isNeedMoreData, + int32_t timeoutMillis = 100) = 0; + }; } } -- cgit v1.2.3 From c1a58778eecd0115d746afbca1079683b244b672 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Thu, 6 Aug 2020 14:47:49 +0300 Subject: Quectel EG25-G Delta Radio Firmware Upgrade support - libmts-io implementation During testing I discrovered that EG25-G radio may lose some data during transmission over Serial AT interface or just freezes and stops responding over Serial AT interface. When ACK mode is not used, the radio may either return an error: ``` Expected: [+QFUPL: 24312545,fa6b], Actual: [+QFUPL: 17124608,b907 +CME ERROR: 409 // Fail to write the file ] ``` Or it may just freeze on modem_at1 interface and stop responding to AT commands: ``` 8:0:34:32|TRACE|RADIO| Sending command [AT] 8:0:34:133|DEBUG|RESULT: 8:0:34:133|DEBUG|Shutting Down ``` This commit implements an alternative, ACK mode for data transmission to prevent data losses. Data is sent in chunks and the device waits for ACK string from the radio for each chunk. --- include/mts/MTS_IO_QuectelRadio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 0f24db8..5199b40 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -73,7 +73,7 @@ namespace MTS { static const std::string VALUE_MTS_DELTA_NAME; static const std::string VALUE_MTS_DELTA_PATH; - CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes); + CODE startFileUpload(const std::string& sTargetFilename, size_t nBytes, uint16_t uRxTimeout = 5, bool bAckEnabled = false); CODE abortFileUpload(); static inline void callNextStep(UpdateCb& stepCb, const char* csMessage); -- cgit v1.2.3 From b32dbb2c5f12fbacf598edb812acab816068de00 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 7 Aug 2020 16:03:56 +0300 Subject: Quectel EG25-G Delta Radio Firmware Upgrade support - libmts-io implementation Small improvements in code comments. --- include/mts/MTS_IO_QuectelRadio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 5199b40..9713f48 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -86,7 +86,7 @@ namespace MTS { CODE fumoWaitUpgradeFinished(UpdateCb& stepCb); CODE fumoWaitNewFirmware(UpdateCb& stepCb); - /// Parse error code in early FUMO URC result received before the first attempt to flash the firmware + /// Parse error code if +QIND: "FOTA" received before the first attempt to flash the firmware std::string getFumoEarlyErrorCode(const std::string& sRadioInput); /// Get value from container by its index, use default value if not found. Non-template version. -- cgit v1.2.3