CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

StrFnd Function

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JeffLewcock



Joined: 10 Apr 2007
Posts: 29

View user's profile Send private message

StrFnd Function
PostPosted: Wed Jan 30, 2013 3:07 pm     Reply with quote

Not sure if this question is really for this forum but here goes

I need but cannot find a good description of strfnd in string.h

I'm trying to work out how it is used in this code snippet
Code:

p1 = StrFnd(GPRMCStr, ',', 0);      //find first comma
   if (p1 == 6)
   {
      //check for valid packet:
      if ( (StrFnd(GPRMCStr, 'A', p1+1) == 18) && (GPRMCStr[0]=='$')) //valid?
      {


An example GPRMCstr is

$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70

so for the first comma position 6 is true

However A is never p1+1 or 18 but code does actually work

Jeff
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 30, 2013 3:19 pm     Reply with quote

from...
$GPRMC,220516,A,5133

1st comma is at position 6

'A' is at position 14

at least that's the way I count it...

not '18'


or am I missing something here ??

hth
jay
JeffLewcock



Joined: 10 Apr 2007
Posts: 29

View user's profile Send private message

PostPosted: Wed Jan 30, 2013 3:28 pm     Reply with quote

Hi Temtronic

No I dont think you're missing anything thats what I though.

I cannot find a good explanation of the strfnd function so cant see what the p1+1 bit is doing either

The code is from here

http://www.ccsinfo.com/forum/viewtopic.php?t=45827&highlight=gprmc+decode

at void GPRMC_decode(char *GPRMCStr, GPRMCInfo *RMCInfo)

and the program as a whole works

I wanted to work out how it works as I want to decode $GPGSA and $GPGSV strings as well

Jeff
JeffLewcock



Joined: 10 Apr 2007
Posts: 29

View user's profile Send private message

PostPosted: Wed Jan 30, 2013 3:46 pm     Reply with quote

I made a mistake, I assumed strfnd was the same as strfind I don't think it is

as strfnd is defined in the program thus
Code:

///////////////////////////////////////////////////////////////////////////////
// find c in s starting from pos st
int8 StrFnd(char *s, char c, size_t st)
{
   int8 l;
   
   for (l=st, s+=st ; *s != '\0' ; l++, s++)
      if (*s == c)
         return l;
   return -1;
}
///////////////////////////////////////////////////////////////////////////////


Still cant work out the "18" though
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Thu Jan 31, 2013 10:39 am     Reply with quote

The function StrFnd(char *s, char c, size_t st) returns the position of the character c in the string s, starting at position st (zero-base index).

Cheers
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Feb 01, 2013 12:34 am     Reply with quote

Where are you finding a 'strfnd' function for PIC-C?

I don't see one at all in string.h nor is it listed in the compiler help manual.

I think you want strchr which is listed in the manual.

(and if you're rolling through GPS sentences, strtok is nice too)

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group