2018-05-26 07: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.
2018-05-27 02: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?
2018-05-27 02:51 AM
That is correct.
2018-05-27 02:53 AM
Cool. Would you mind sharing the UART bits for the F7 with me?
2018-05-27 03:18 AM
I did about 5 hours ago
still under moderation
:(
2018-05-27 03: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.
2018-05-27 03:40 AM
me too
2018-05-27 03: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.
2018-05-27 04:24 AM
Thanks to both of you for digging into this mystery!
2018-05-27 05:24 AM
Thanks!