AnsweredAssumed Answered

Communication between UART DMA and ESP8266 hangs after first response

Question asked by Lars Beiderbecke on May 26, 2018
Latest reply on May 27, 2018 by Lars Beiderbecke

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.

Outcomes