Repeat Nmea

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Repeat Nmea

Post by Mast » Thu Oct 04, 2007 7:06 pm

I have a problem with the "IF" of the Nmea module.

Code: Select all

IF NMEA.GetItem(NMEAItem) AND NMEAItem.Valid THEN
      NMEA.GetField(NMEAItem,0,Field)

     IF  Field = "$GPRMC"   THEN  
        NMEA.GetField(NMEAItem,0,Field)
        GLCD.SetFont(Fixed)      

        NMEA.GetField(NMEAItem, 3, FieldLat)   'recupere Latitude
        GLCD.WriteAt(1,55,FieldLat)
                  
        NMEA.GetField(NMEAItem, 4, FieldLat)   'recupere N
        GLCD.WriteAt(56,55,FieldLat)
        
         NMEA.GetField(NMEAItem, 5, FieldLon)   'recupere Longitude
        GLCD.WriteAt(62,55,FieldLon)
        
        NMEA.GetField(NMEAItem, 6, FieldLon)   'recupere W ou E
        GLCD.WriteAt(122,55,FieldLon)  
                         
        NMEA.GetField(NMEAItem, 8, Field)  'recupere CAP        
        Field = Left(Field,3)
        data1 = StrToDec(Field)
        text4 = DecToStr(data1)
       END IF
    
END IF  'nmea   
When i change for "Repeat" cause "If" is not suffisant (i have delay in my prog), Repeat don't work. i can't go outside the Repeat until, and no answer on the screen.

Code: Select all

IF NMEA.GetItem(NMEAItem) AND NMEAItem.Valid THEN
      NMEA.GetField(NMEAItem,0,Field)

     Repeat   
        NMEA.GetField(NMEAItem,0,Field)
        GLCD.SetFont(Fixed)      

        NMEA.GetField(NMEAItem, 3, FieldLat)   'recupere Latitude
        GLCD.WriteAt(1,55,FieldLat)
                  
        NMEA.GetField(NMEAItem, 4, FieldLat)   'recupere N
        GLCD.WriteAt(56,55,FieldLat)
        
         NMEA.GetField(NMEAItem, 5, FieldLon)   'recupere Longitude
        GLCD.WriteAt(62,55,FieldLon)
        
        NMEA.GetField(NMEAItem, 6, FieldLon)   'recupere W ou E
        GLCD.WriteAt(122,55,FieldLon)  
                         
        NMEA.GetField(NMEAItem, 8, Field)  'recupere CAP        
        Field = Left(Field,3)
        data1 = StrToDec(Field)
        text4 = DecToStr(data1)
      
Until Field = "$GPRMC" 
    
END IF  'nmea   

Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Post by Mast » Fri Oct 05, 2007 6:58 am

If i andestand ! "Repeat and Until" don't work with a String ! :shock:

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Fri Oct 05, 2007 8:49 am

I don't think the code you posted shows that repeat...until does not work with a string! The logic of your program looks flawed.

(a) GetItem() is outside your repeat loop - how do you pick up new data?
(b) Field = Left(Field,3) - how can a three character string ever equal "$GPRMC"?

Here is some code showing repeat...until working with a string

Code: Select all

Include "usart.bas"
Include "convert.bas"
dim Str as string
dim Index as byte

SetBaudrate(br115200)
Index = 0
Str = ""
repeat
   write(DecToStr(index),13,10)
   inc(Index)
   if Index > 10 then
      Str = "BOO"
   endif   
until Str = "BOO"
write("Finished",13,10)

Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Post by Mast » Fri Oct 05, 2007 2:01 pm

Thanks david, i think now the code is good.

Code: Select all

    REPEAT  
    
IF NMEA.GetItem(NMEAItem) AND NMEAItem.Valid THEN
             NMEA.GetField(NMEAItem,0,FieldLL)              
       
        NMEA.GetField(NMEAItem, 3, FieldLat)   'recupere Latitude                
        NMEA.GetField(NMEAItem, 4, FieldLatN)   'recupere N        
        NMEA.GetField(NMEAItem, 5, FieldLon)   'recupere Longitude        
        NMEA.GetField(NMEAItem, 6, FieldLonWE)   'recupere W ou E        
        NMEA.GetField(NMEAItem, 8, FieldCap)  'recupere CAP 
                                                              
END IF  'nmea  
    UNTIL FieldLL = "$GPRMC"
    
                Fieldcap = Left(Fieldcap,3)
                data1 = StrToDec(Fieldcap)
                text4 = DecToStr(data1)
         GLCD.SetFont(Fixed)              
'--------------------------------------     
        GLCD.WriteAt(1,55,FieldLat)
        GLCD.WriteAt(56,55,FieldLatN)           
        GLCD.WriteAt(62,55,FieldLon)
        GLCD.WriteAt(122,55,FieldLonWE)   

Post Reply