[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] strtok_r
From: |
Dave Hylands |
Subject: |
Re: [avr-gcc-list] strtok_r |
Date: |
Sun, 29 Jun 2008 07:43:25 -0700 |
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
http://www.DaveHylands.com/