-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response Issue in CMUX Mode (IDFGH-12431) #536
Comments
just for me to understand, you're expecting a response pre-pended by Maybe an alternative approach could be to use |
Hi David |
I try the |
Thanks for sharing the log. Is it possible that some command before that failed or timeouted? (and it passed while running on 80MHz?) I think we can workaround it simply by flushing the Rx buffer before each command. (perhaps this would sound like a solution, because we do not need the data from previous commands, but I'd still like to understand where this |
The shared log is showing the first nmea request we sent and its response. When I checked the logs, there is no fail or timeout situation:) With the solution 'flushing the rx buffer', my concern is that we can also flush the internet related data because we are also using the gsm module at the same time and its data is also coming from same uart. (One uart connection to the module and CMUX configuration) |
This should work, I don't see any downside other than the effective response time. One theory for the extra diff --git a/components/esp_modem/src/esp_modem_command_library.cpp b/components/esp_modem/src/esp_modem_command_library.cpp
index 6f06bb7..e491b3f 100644
--- a/components/esp_modem/src/esp_modem_command_library.cpp
+++ b/components/esp_modem/src/esp_modem_command_library.cpp
@@ -373,7 +373,7 @@ command_result send_sms(CommandableIf *t, const std::string &number, const std::
command_result set_cmux(CommandableIf *t)
{
ESP_LOGV(TAG, "%s", __func__ );
- return generic_command_common(t, "AT+CMUX=0\r");
+ return generic_command_common(t, "AT+CMUX=0\r", 5000);
}
command_result read_pin(CommandableIf *t, bool &pin_ok)
diff --git a/components/esp_modem/src/esp_modem_dce.cpp b/components/esp_modem/src/esp_modem_dce.cpp
index 55c51f0..cce4684 100644
--- a/components/esp_modem/src/esp_modem_dce.cpp
+++ b/components/esp_modem/src/esp_modem_dce.cpp
@@ -135,7 +135,10 @@ bool DCE_Mode::set_unsafe(DTE *dte, ModuleIf *device, Netif &netif, modem_mode m
if (mode == modem_mode::DATA_MODE || mode == modem_mode::CMUX_MODE || mode >= modem_mode::CMUX_MANUAL_MODE) {
return false;
}
- device->set_mode(modem_mode::CMUX_MODE); // switch the device into CMUX mode
+ if (!device->set_mode(modem_mode::CMUX_MODE)) {
+ return false;
+ }
+ // switch the device into CMUX mode
usleep(100'000); // some devices need a few ms to switch
if (!dte->set_mode(modem_mode::CMUX_MODE)) { |
I see, thanks for testing. the issue is apparently somewhere else. Could you please share your sdkconfig (I'm only interested in If it's the case, could you please try to enable |
"From what I can see, you had ESP_MODEM_CMUX_DEFRAGMENT_PAYLOAD set to n, correct?", it is set to 'y' Here is the related part.
And i used various settings :) When I saw the issue , I thought that the response is coming in two pieces too. But I think it is not the case because in logic analyzer there is no delay between 'Sentence' and 'OK' and uart buffer has the "OK" when we read the 'sentence' from dte buffer. Here is how I got the log:
Thank you |
Okay, seems I was wrong again. The response may or may not come in two pieces, but it comes in two distinct cmux messages, now I see it from your logic analyzer picture (was confused by the logs seeing only ascii characters). I think you've already tried, but still:
|
It seems like an issue in the modem code (which doesn't exhibit very often, as I've never seen two such a small fragments posted in two cmux frames, which is a legitimate usecase). The question is why we won't get the second callback. --- a/components/esp_modem/src/esp_modem_uart.cpp
+++ b/components/esp_modem/src/esp_modem_uart.cpp
@@ -120,6 +120,7 @@ void UartTerminal::task()
switch (event.type) {
case UART_DATA:
uart_get_buffered_data_len(uart.port, &len);
+ ESP_LOGW(TAG, "UART_DATA %d", len);
if (len && on_read) {
on_read(nullptr, len);
}
This actually explains that we get the correct data in two cmux callbacks, but only one uart callback (but not via two uart callbacks). If this is the case, then this should fix the problem: --- a/components/esp_modem/src/esp_modem_uart.cpp
+++ b/components/esp_modem/src/esp_modem_uart.cpp
@@ -160,6 +160,11 @@ void UartTerminal::task()
ESP_LOGW(TAG, "unknown uart event type: %d", event.type);
break;
}
+ } else {
+ uart_get_buffered_data_len(uart.port, &len);
+ if (len && on_read) {
+ on_read(nullptr, len);
+ }
}
}
} (which basically just periodically checks for any potential data buffered in case we missed an event) |
Thanks for testing it and for the good news. I've just put up a PR with the fix. It usually takes few days for people to review it before it gets merged. I'll also add a bump commit, so we'll publish a new version to component manager. |
1.2.0 Features - Add support for guessing mode (52598e5) - Delete CMUX internal implementation even if terminal exit fails (0e0cbd6) - Add support for handling URC (1b6a3b3, espressif#180) - add ability to change ESP_MODEM_C_API_STR_MAX from Kconfig (1790989) - Added target test config with CHAP authentication (f8ae7de) - example add esp32p4 usb support (adafeae) - Publish mbedtls component (0140455) - host test support of the latest ESP-IDF release (3f74b4e) Bug Fixes - Fix console example to use urc/detect features (1a9eaf3) - Update target test builds to use external Catch2 (554f022) - Fix arguments names when spawn esp_modem_xxx declarations (b6792c5) - Remove catch dependency (c348076) - Examples: use local configs for MQTT topic/data (f5c13b9) - Fixed clang-tidy warnings (70fa3af) - Fix CI build per IDFv5.3 (d0c17ef) - Fixed UART task to check for buffered data periodically (4bdd90c, espressif#536) - Cleanup unused configs from PPPoS example (08a62cc) - Update CMUX example with SIM7070_gnss cleaned-up (56fe532) - Update console example with SIM7070_gnss format comments (5baaf54) - Fix remaining print format warnings (3b80181) Updated - docs(modem): Fix esp_modem_at_raw() description (C-API) (492a6a0) - ci(common): updated github actions(checkout, upload, download) v3 to 4, Ubuntu 20.04 to v22.04 (a23a002)
Answers checklist.
General issue report
Environment:
Problem Description:
We are utilizing the Quectel MC60 module in conjunction with the ESP32-S3, employing the ESP-MODEM component for communication. Our application involves connecting to the internet via the MC60's all-in-one solution and periodically requesting NMEA sentences.
Issue:
In CMUX mode, after successfully establishing an internet connection and receiving an IP address, we attempt to fetch GLL NMEA sentences using the command "AT+QGNSSRD" periodically. The MC60 appears to respond correctly with the requested sentence followed by an "OK" acknowledgment. However, In the initial response, we receive only "nmeasentence" without the preceding "OK". Subsequent requests then yield an "OK" response that seems to belong to the previous request, leading to a cycle where each NMEA sentence request is followed by an "OK" from the prior request, effectively causing empty responses and misaligned confirmations.
Observations:
The entire response (including "OK") is present in the UART buffer, suggesting that the issue might be with how the response is processed or retrieved.
We employ
esp_modem::dce_commands::generic_get_string
to capture the response.The issue consistently occurs when the ESP system clock is set to either 240 MHz or 160 MHz.
Interestingly, adding a delay at the beginning of the bool
DTE::command_cb::process_line
function mitigates the issue.At an 80 MHz ESP system clock frequency, the problem does not occur, and the system behaves as expected, receiving both the NMEA sentence and the "OK" acknowledgment without issues.
Upon inspecting the communication with a logic analyzer on the MC60 side, it is observed that the module transmits the complete response (sentence + "OK") as expected, indicating that the UART transmission from the MC60 is functioning correctly.
Request:
Could you provide insight or a solution to this problem? It appears that system clock frequencies above 80 MHz introduce timing issues with UART communication or processing within the ESP-MODEM component, specifically in the context of receiving complete responses from the MC60 module. The observation with a logic analyzer suggests that the issue lies not in the MC60's transmission but possibly in the reception or processing of the data by the ESP32-S3 or the ESP-MODEM component.
Thank you for your assistance.
The text was updated successfully, but these errors were encountered: