mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #8790 from AriParkkila/cell-urc-cb
Cellular: Fix ATHandler URC processingpull/8867/head
commit
3c0d6f0b0c
|
@ -72,7 +72,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
|
||||||
_previous_at_timeout(timeout),
|
_previous_at_timeout(timeout),
|
||||||
_at_send_delay(send_delay),
|
_at_send_delay(send_delay),
|
||||||
_last_response_stop(0),
|
_last_response_stop(0),
|
||||||
_processing(false),
|
_oob_queued(false),
|
||||||
_ref_count(1),
|
_ref_count(1),
|
||||||
_is_fh_usable(true),
|
_is_fh_usable(true),
|
||||||
_stop_tag(NULL),
|
_stop_tag(NULL),
|
||||||
|
@ -223,9 +223,8 @@ bool ATHandler::find_urc_handler(const char *prefix)
|
||||||
|
|
||||||
void ATHandler::event()
|
void ATHandler::event()
|
||||||
{
|
{
|
||||||
// _processing must be set before filehandle write/read to avoid repetitive sigio events
|
if (!_oob_queued) {
|
||||||
if (!_processing) {
|
_oob_queued = true;
|
||||||
_processing = true;
|
|
||||||
(void) _queue.call(Callback<void(void)>(this, &ATHandler::process_oob));
|
(void) _queue.call(Callback<void(void)>(this, &ATHandler::process_oob));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,14 +234,12 @@ void ATHandler::lock()
|
||||||
#ifdef AT_HANDLER_MUTEX
|
#ifdef AT_HANDLER_MUTEX
|
||||||
_fileHandleMutex.lock();
|
_fileHandleMutex.lock();
|
||||||
#endif
|
#endif
|
||||||
_processing = true;
|
|
||||||
clear_error();
|
clear_error();
|
||||||
_start_time = rtos::Kernel::get_ms_count();
|
_start_time = rtos::Kernel::get_ms_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATHandler::unlock()
|
void ATHandler::unlock()
|
||||||
{
|
{
|
||||||
_processing = false;
|
|
||||||
#ifdef AT_HANDLER_MUTEX
|
#ifdef AT_HANDLER_MUTEX
|
||||||
_fileHandleMutex.unlock();
|
_fileHandleMutex.unlock();
|
||||||
#endif
|
#endif
|
||||||
|
@ -283,19 +280,22 @@ void ATHandler::process_oob()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lock();
|
lock();
|
||||||
|
_oob_queued = false;
|
||||||
if (_fileHandle->readable() || (_recv_pos < _recv_len)) {
|
if (_fileHandle->readable() || (_recv_pos < _recv_len)) {
|
||||||
tr_debug("AT OoB readable %d, len %u", _fileHandle->readable(), _recv_len - _recv_pos);
|
tr_debug("AT OoB readable %d, len %u", _fileHandle->readable(), _recv_len - _recv_pos);
|
||||||
_current_scope = NotSet;
|
_current_scope = NotSet;
|
||||||
uint32_t timeout = _at_timeout;
|
uint32_t timeout = _at_timeout;
|
||||||
_at_timeout = PROCESS_URC_TIME;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
_at_timeout = timeout;
|
||||||
if (match_urc()) {
|
if (match_urc()) {
|
||||||
if (!(_fileHandle->readable() || (_recv_pos < _recv_len))) {
|
if (!(_fileHandle->readable() || (_recv_pos < _recv_len))) {
|
||||||
break; // we have nothing to read anymore
|
break; // we have nothing to read anymore
|
||||||
}
|
}
|
||||||
} else if (mem_str(_recv_buff, _recv_len, CRLF, CRLF_LENGTH)) { // If no match found, look for CRLF and consume everything up to CRLF
|
} else if (mem_str(_recv_buff, _recv_len, CRLF, CRLF_LENGTH)) { // If no match found, look for CRLF and consume everything up to CRLF
|
||||||
|
_at_timeout = PROCESS_URC_TIME;
|
||||||
consume_to_tag(CRLF, true);
|
consume_to_tag(CRLF, true);
|
||||||
} else {
|
} else {
|
||||||
|
_at_timeout = PROCESS_URC_TIME;
|
||||||
if (!fill_buffer()) {
|
if (!fill_buffer()) {
|
||||||
reset_buffer(); // consume anything that could not be handled
|
reset_buffer(); // consume anything that could not be handled
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -218,7 +218,7 @@ private:
|
||||||
uint16_t _at_send_delay;
|
uint16_t _at_send_delay;
|
||||||
uint64_t _last_response_stop;
|
uint64_t _last_response_stop;
|
||||||
|
|
||||||
bool _processing;
|
bool _oob_queued;
|
||||||
int32_t _ref_count;
|
int32_t _ref_count;
|
||||||
bool _is_fh_usable;
|
bool _is_fh_usable;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue