Subversion Repositories libNMEA

Rev

Rev 4 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 5
Line 30... Line 30...
30
static bool
30
static bool
31
decodePacket(char *linebuff, int linePos, Location *loc);
31
decodePacket(char *linebuff, int linePos, Location *loc);
32
 
32
 
33
bool updateLocation(Location *loc, usart_ctl *uc)
33
bool updateLocation(Location *loc, usart_ctl *uc)
34
{
34
{
35
        unsigned chars = SerialCharsReceived(uc);
35
        while(PollSerial(uc))
36
        if (!chars)
-
 
37
                return false; // nothing to read, return immediately
-
 
38
 
-
 
39
        for (int i = 0; i < chars; i++)
-
 
40
        {
36
        {
41
                char c = GetCharSerial(uc);
37
                char c = GetCharSerial(uc);
42
                switch (lineState)
38
                switch (lineState)
43
                {
39
                {
44
                case SEARCH:
40
                case SEARCH:
Line 50... Line 46...
50
                        if (c == '\r')
46
                        if (c == '\r')
51
                        {
47
                        {
52
                                // log the actual time of reading
48
                                // log the actual time of reading
53
 
49
 
54
                                // handle the packet
50
                                // handle the packet
55
                                bool success = decodePacket(linebuff, linePos, loc);
51
                                decodePacket(linebuff, linePos, loc);
56
 
52
 
57
                                lineState = SEARCH;
53
                                lineState = SEARCH;
58
 
-
 
59
                                linePos = 0;
54
                                break;
60
                                return success;
-
 
61
                        }
55
                        }
62
                        // if the line buffer is not full, place character in buffer
56
                        // if the line buffer is not full, place character in buffer
63
                        if (linePos < sizeof(linebuff))
57
                        if (linePos < sizeof(linebuff))
64
                                linebuff[linePos++] = c;
58
                                linebuff[linePos++] = c;
65
                        else
59
                        else