mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Drain the serial queue of invalid data.
This commit is contained in:
@@ -867,6 +867,7 @@ RESP_TYPE_MMDVM CModem::getResponse(unsigned char *buffer, unsigned int& length)
|
|||||||
assert(buffer != NULL);
|
assert(buffer != NULL);
|
||||||
|
|
||||||
// Get the start of the frame or nothing at all
|
// Get the start of the frame or nothing at all
|
||||||
|
for (;;) {
|
||||||
int ret = m_serial.read(buffer + 0U, 1U);
|
int ret = m_serial.read(buffer + 0U, 1U);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LogError("Error when reading from the modem");
|
LogError("Error when reading from the modem");
|
||||||
@@ -876,10 +877,11 @@ RESP_TYPE_MMDVM CModem::getResponse(unsigned char *buffer, unsigned int& length)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return RTM_TIMEOUT;
|
return RTM_TIMEOUT;
|
||||||
|
|
||||||
if (buffer[0U] != MMDVM_FRAME_START)
|
if (buffer[0U] == MMDVM_FRAME_START)
|
||||||
return RTM_TIMEOUT;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret = m_serial.read(buffer + 1U, 1U);
|
int ret = m_serial.read(buffer + 1U, 1U);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LogError("Error when reading from the modem");
|
LogError("Error when reading from the modem");
|
||||||
return RTM_ERROR;
|
return RTM_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user