[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] strtok_r

From: Gerard Marull Paretas
Subject: Re: [avr-gcc-list] strtok_r
Date: Sun, 29 Jun 2008 19:48:21 +0200

I'm just looking for the hex value after '*' character, so strtok should return a pointer to the first number, right?

Thanks, Gerard

On Sun, Jun 29, 2008 at 4:43 PM, Dave Hylands <address@hidden> wrote:
Hi Gerard,

> The string is
> "$GPGGA,070250.00,4159.08406,N,00301.18212,E,1,08,1.34,00048,M,050,M,,*62"
> (pointed by char *buffer)

> token = strtok_r(buffer,"*", &save_ptr);
> if(token == NULL) return S_ERR;
> //The following lines send the content using usart, so I can see the values
> usart_send(*token);
> usart_send(*(token+1));
> The values sent trough usart, are "$G". If I use save_ptr instead of token
> in the usart_send calls, the result is "62" (as it should be using
> token...). The * character is always replaced by 0, so it seems to work.
> Maybe I'm missing something?

Based on your description, it seems to be working perfectly.

If you're trying to break things up on the commas, then you need to
pass the comma in as a delimiter.

And the second and subsequent times, you'd pass in NULL instead of the buffer.

Dave Hylands
Vancouver, BC, Canada

Gerard Marull Paretas <> address@hidden
Flickr Photo Album: http://www.flickr.com/photos/gerard_mp
reply via email to

[Prev in Thread] Current Thread [Next in Thread]