1
\$\begingroup\$

EDIT: Solved, Problem was with not sending "\r\n" at the end of the sentence.

I'm trying to control Adafruit Ultimate GPS through STM32F407, there is an official Arduino Library and this library has a sendCommand() function. I'm trying to implement this sendCommand() function in Keil using HAL library

// arduino command for setting antenna off
GPS.sendCommand("$PGCMD,33,0*6D\n");

In keil I wrote these lines

uint8_t Tx_Buffer[100];
int size;

// Turn off antenna update nuisance data
size = sprintf(Tx_Buffer,"$PGCMD,33,0*6D\n");
HAL_UART_Transmit(&huart1, Tx_Buffer, size, 100);
HAL_Delay(100);

// Set the update speed
size = sprintf(Tx_Buffer,"$PMTK220,500*2B\n");
HAL_UART_Transmit(&huart1, Tx_Buffer, size, 100);
HAL_Delay(100);

// Request RMC and GGA sentences only
size = sprintf(Tx_Buffer,"$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\n");    
HAL_UART_Transmit(&huart1, Tx_Buffer ,size, 100);
HAL_Delay(1000);

However, it seems that I am not changing anyting because it is still giving data in defaults settings. UART Baudrate is 9600 (Transmit and receive)

Can you help me with the C code? Thanks in advance.

\$\endgroup\$
  • \$\begingroup\$ You're missing a '\n' on the end of your 'Set the update speed' command. \$\endgroup\$ – brhans May 7 '18 at 20:29
  • \$\begingroup\$ Thank you for your response. I tried it before, just missed it at last run. In addition I tried running it with "\n\r" too. \$\endgroup\$ – Zed K. May 8 '18 at 4:54
  • 1
    \$\begingroup\$ @ZiyaKeskin “\n\r” would be very uncommon. Typically either “\n” or “\r\n”. \$\endgroup\$ – Blair Fonville May 8 '18 at 4:56
  • 1
    \$\begingroup\$ I just tried it with "\r\n", and it is working. Thanks for your responses. \$\endgroup\$ – Zed K. May 8 '18 at 5:38
  • 1
    \$\begingroup\$ Please post an answer containing exactly that information, @ZiyaKeskin. It will allow us to recognize this question as answered, and will thus help others more, and as a bonus, you can earn more reputation points that way. \$\endgroup\$ – Marcus Müller May 9 '18 at 17:07
1
\$\begingroup\$

Problem was with not sending "\r\n" at the end of the sentence.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.