1 |
douglas |
22 |
// Dash Interface |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
douglas |
25 |
#include <iostream> |
8 |
|
|
|
9 |
|
|
#include <foreach.hpp> |
10 |
|
|
#include <hash.hpp> |
11 |
douglas |
26 |
#include <regex.hpp> |
12 |
douglas |
25 |
|
13 |
douglas |
24 |
#include <Audacious.hpp> |
14 |
|
|
#include <GPS.hpp> |
15 |
|
|
|
16 |
douglas |
25 |
#include <sqlite3.h> |
17 |
|
|
|
18 |
douglas |
26 |
#include "Display.hpp" |
19 |
|
|
|
20 |
|
|
bool debug(false); |
21 |
|
|
|
22 |
douglas |
22 |
int main(int argc, char *argv[]) |
23 |
|
|
{ |
24 |
douglas |
26 |
std::string device; |
25 |
|
|
|
26 |
douglas |
25 |
{ |
27 |
douglas |
26 |
Pcre::RegEx devicePath(_B("^-device=(/.+)$")); |
28 |
|
|
Pcre::RegEx deviceNumber(_B("^-device=([0-9]+)$")); |
29 |
|
|
Pcre::RegEx deviceName(_B("^-device=(.+)$")); |
30 |
douglas |
25 |
|
31 |
douglas |
26 |
for (char **arg = argv + 1; *arg; ++arg) |
32 |
douglas |
25 |
{ |
33 |
douglas |
26 |
Pcre::RegEx::Match match; |
34 |
douglas |
25 |
|
35 |
douglas |
26 |
if (*arg == _B("-debug")) |
36 |
|
|
debug = true; |
37 |
|
|
else if (match = devicePath(*arg)) |
38 |
|
|
device = match[1]; |
39 |
|
|
else if (match = deviceNumber(*arg)) |
40 |
|
|
device = _B("/dev/cuaU") + match[1]; |
41 |
|
|
else if (match = deviceName(*arg)) |
42 |
|
|
device = _B("/dev/") + match[1]; |
43 |
|
|
else |
44 |
|
|
goto usage; |
45 |
douglas |
25 |
} |
46 |
|
|
} |
47 |
douglas |
26 |
|
48 |
|
|
if (device.empty()) |
49 |
|
|
{ |
50 |
|
|
usage: std::cout << _B("Usage: ") << argv[0] << _B(" [-debug] [-device=device]") << std::endl; |
51 |
|
|
|
52 |
|
|
return 2; |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
try |
56 |
|
|
{ |
57 |
|
|
//enum Mode { Uname, Music, English, Metric, Nautical, Last } mode(Uname); |
58 |
|
|
//Audacious audacious; |
59 |
|
|
Display display(device); |
60 |
|
|
|
61 |
|
|
display.Ping("Hello!"); |
62 |
|
|
|
63 |
douglas |
28 |
std::cout << display.Version() << std::endl; |
64 |
|
|
|
65 |
|
|
display.Store(); |
66 |
|
|
display.Clear(); |
67 |
|
|
|
68 |
douglas |
26 |
/*GPS::GPS gps; |
69 |
|
|
|
70 |
|
|
gps.Query(_B("o")); |
71 |
|
|
|
72 |
|
|
std::cout << gps.GetLatitude() << std::endl;*/ |
73 |
|
|
} |
74 |
douglas |
25 |
catch (const std::exception &exception) |
75 |
|
|
{ |
76 |
|
|
std::cerr << argv[0] << _B(": ") << exception.what() << std::endl; |
77 |
|
|
|
78 |
|
|
return 1; |
79 |
|
|
} |
80 |
|
|
|
81 |
douglas |
22 |
return 0; |
82 |
|
|
} |