ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/Display.cpp
(Generate patch)

Comparing GPS/GPS.cpp (file contents):
Revision 23 by douglas, 2008-02-08T07:13:30-08:00 vs.
Revision 25 by douglas, 2008-02-09T01:39:22-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #include <gps.h>
7 > #include <cerrno>
8 > #include <iostream>
9 > #include <sstream>
10 >
11 > #include <posix.hpp>
12  
13   #include "GPS.hpp"
14 +
15 + namespace GPS
16 + {
17 +
18 + Error::Error()
19 + {
20 +        std::ostringstream message;
21 +
22 +        message << _B("GPS[#") << errno << _B("] ");
23 +
24 +        switch (errno)
25 +        {
26 +        case NL_NOSERVICE:
27 +                message << _B("can't get service entry");
28 +
29 +                break;
30 +        case NL_NOHOST:
31 +                message << _B("can't get host entry");
32 +
33 +                break;
34 +        case NL_NOPROTO:
35 +                message << _B("can't get protocol entry");
36 +
37 +                break;
38 +        case NL_NOSOCK:
39 +                message << _B("can't create socket");
40 +
41 +                break;
42 +        case NL_NOSOCKOPT:
43 +                message << _B("error SETSOCKOPT SO_REUSEADDR");
44 +
45 +                break;
46 +        case NL_NOCONNECT:
47 +                message << _B("can't connect to host");
48 +
49 +                break;
50 +        }
51 +
52 +        this->message = message.str();
53 + }
54 +
55 + GPS::GPS(const std::string &host, const std::string &port) : gps(::gps_open(host.c_str(), port.c_str()))
56 + {
57 +        if (gps == NULL)
58 +                throw Error();
59 + }
60 +
61 + void GPS::Poll()
62 + {
63 +        Posix::CheckError(::gps_poll(gps));
64 + }
65 +
66 + void GPS::Query(const std::string &query)
67 + {
68 +        Posix::CheckError(::gps_query(gps, query.c_str()));
69 + }
70 +
71 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines