简体   繁体   中英

how to read data from quectel L89 GPS module in stm32 using HAL_UART_Receive()?

I am using STM32F103C8T6 board and CubeMX to generate the code. I need to receive the GPS data from Quectel L89 module from UART2 port. when I try that I get some junk values only... I am using HAL_UART_Receive to receive data and print it in the putty console. Any help would be greatly appreciated.

This is my code.

void task1(void)
{


char *buffer = NULL;
  buffer = (char*)malloc(400 * sizeof(char));
  while(1)
  {
  HAL_UART_Receive(&huart2,buffer,350,500);
  int size = strlen(buffer);

  HAL_UART_Transmit(&huart1,buffer,size,500);
  HAL_Delay(1000);
  }

}

Image of the Result

try this

HAL_UART_Receive(&huart2,(uint8_t *)buffer,350,500);

and

HAL_UART_Transmit(&huart1,(uint8_t *)buffer,size,500);

Because arguments needed for HAL functions are of uint8_t * type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM