Communication between UART DMA and ESP8266 hangs after first response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-26 7:04 AM
I'm going crazy with this. I want to send some commands to an ESP8266, and search the response for 'OK'. Since the response is of arbitrary length, I'm receiving 400 bytes, and see if there's an 'OK' in there. If there isn't within a given timeout, the operation fails.
clearBuffer(buffer);
HAL_UART_Receive_DMA(&huart7, rxbuffer, 400);HAL_UART_Transmit_DMA(&huart7, 'OK' CRLF, 4);buf = waitOK(buffer, 3); // wait 3 secs for 'OK'HAL_UART_Transmit_DMA(&huart7, 'OK' CRLF, 4);buf = waitOK(buf, 3); // wait 3 secs for 'OK'// ...static uint8_t *waitOK(uint8_t *buf, int timeout) { uint8_t *found = 0; int count = 0; while (count++ < 2 * timeout) { found = strfind(buf, 'OK'); // search for 'OK' in remaining buffer if (found) break; HAL_Delay(500); } return found + 1;}Unfortunately, I can only get the first OK. Subsequent commands don't receive ANY response, i.e., the buffer remains empty.
I configured UART7 with two DMA channels, but no interrupt. No callbacks have been defined.
What am I doing wrong here? I've tried multiple variations, with IR or polling, but they all showed the same issue.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 2:51 AM
I also finally did as you suggested. I connected RX of the ESP8266 to a different console, and had your Forward() process the responses send by TX of the ESP8266.
That worked beautifully, I could see the echo and the response of each command.
But what does this mean?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 2:51 AM
That is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 2:53 AM
Cool. Would you mind sharing the UART bits for the F7 with me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 3:18 AM
I did about 5 hours ago
still under moderation
:(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 3:38 AM
And I use CubeMX 4.25, and both are linear buffers. I didn't write any callbacks, I'm just using the generated code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 3:40 AM
me too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 3:42 AM
I only setup the RxDMA on startup.
I use peek() to check a pending byte in the buffer
I use readable() to check the length of the received packet, before I go get it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 4:24 AM
Thanks to both of you for digging into this mystery!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-27 5:24 AM
Thanks!

- « Previous
-
- 1
- 2
- Next »