Skip to main content
PTsen
Associate III
December 24, 2018
Solved

Can't communicate properly with X-NUCLEO-GNSS1A1

  • December 24, 2018
  • 1 reply
  • 3140 views

Hi, as the title said, I am having the hard time communicating with X-NUCLEO-GNSS1A1

The GNSS module is communicate via USART (can't communicate via I2C, but this is the other problem)

the code is written as follow:

void usart_setup(void)
{
 // some setup .....
}
 
volatile char gnss[180];
 
 
void gnss(void* args __attribute__((unused)))
{
 for(;;)
 {
 int i = 0;
		for (char a = usart_recv_blocking(USART1); a != '\r' || i < 180; a = usart_recv_blocking(USART1), ++i)
		{
			gnss[i] = a;
		}
 }
}
 
void usart_status_updater(TimerHandle_t xTimer)
{
	printf("%s\n\r", gnss);
}
 
int main(void)
{
 usart_send_stat_timer = xTimerCreate("USART_TIM", STATUS_UPDATE_PRD, pdTRUE, (void *) 0, usart_status_updater);
 xTaskCreate(gnss, "gnss", 1024, NULL, configMAX_PRIORITIES - 1, NULL);
 
	xTimerStart(usart_send_stat_timer, 0);
	vTaskStartScheduler();
}

For some reason, I cannot use HAL/LL library, and I'm using opencm3, but I think this is not the reason, also, there is some freeRTOS stuff inside, but it also should not be the reason, the result is shown in the picture

0690X000006CuzcQAC.jpg

As one can see, the command of the message doesn't show properly, e.g. "$SA" instead of $GPGSA "", having a larger buffer does not solve the problem. What should I do to fix the problem?

I have read the src code in CubeMS, and it is really hard to understand it, also there is a little example online, so I am literally in the dark, the software manual is not that clear IMO, even though I know those command, but I simply can't produce expected result.

This is only one of the problems, any advice or idea will be appreciated, thank you

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    The GNSS streams ASCII data, it is not complex. You have no synchronization between multiple tasks. Waiting for characters to arrive will block, printing characters/strings will block. The stream does not stop to make things convenient for you, and the USART hardware will not buffer data.

    >>What should I do to fix the problem?

    Decide how you're going to handle the data and the inter-task communication. Decide if you understand the dynamics sufficiently to use multiple tasks, and if not handle it more linearly.

    I've posted NMEA examples to the forum on multiple occasions, I'd recommend collecting lines in the USART IRQ handler, and then queuing the complete sentences to a task that then parsing and prints the lines.

    1 reply

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    December 24, 2018

    The GNSS streams ASCII data, it is not complex. You have no synchronization between multiple tasks. Waiting for characters to arrive will block, printing characters/strings will block. The stream does not stop to make things convenient for you, and the USART hardware will not buffer data.

    >>What should I do to fix the problem?

    Decide how you're going to handle the data and the inter-task communication. Decide if you understand the dynamics sufficiently to use multiple tasks, and if not handle it more linearly.

    I've posted NMEA examples to the forum on multiple occasions, I'd recommend collecting lines in the USART IRQ handler, and then queuing the complete sentences to a task that then parsing and prints the lines.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    PTsen
    PTsenAuthor
    Associate III
    December 24, 2018

    Hi, thanks for your quick response, I'll try using IRQ tomorrow. I'll update the result asap.