0
\$\begingroup\$

I am receiving coordinates from my GPS module like mentioned on below.

uint8_t *latPtr = tmpPtr + 1;

when I am writing latPtr value in UART I can view lat value in terminal.

uartwrite(latPtr); // output is 1257.4370N

Find my uartwrite function on below

void uartwrite( char *data)  
{
  while(*data)
  {
    EUSART_Write(*data);
    *data++;   
  }
}

Now I want to convert the lat value in to degree minutes seconds format. So that I have written below mentioned code on my main file

float res1=*lonPtr;

float flo=res1/100;
int ilong=flo;

float lati=flo-ilong;
float res1=lati*60;
int minutes=res1;
uartwrite(minutes);

float isec=res1-minutes;
int lasec=isec*60;     
uartwrite(lasec);
uartwrite("\n\r");

how to send DMS to UART?

\$\endgroup\$
  • \$\begingroup\$ This output, what format is this? \$\endgroup\$ – sweber May 27 '17 at 5:57
  • 1
    \$\begingroup\$ Apparently you have a pointer to a string. You must convert that string to a (floating point) numerical type ("atof"), do your calculations, and convert the results back to a string for output. "float res1=*lonPtr;" won't do. \$\endgroup\$ – JimmyB May 27 '17 at 17:01
  • \$\begingroup\$ I have used atof ( float res1=atof(data);) and its working \$\endgroup\$ – user1811790 May 29 '17 at 12:28

Your Answer

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

Browse other questions tagged or ask your own question.