nmea 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,65 +0,0 @@
1
- #include "nmea.h"
2
-
3
- VALUE mGPS, mNMEA, cLatitude, cLongitude, cTime, eParseError, cSatelliteInfo;
4
- ID id_GPS, id_Latitude, id_Longitude, id_new, id_rmc;
5
- ID id_gsv, id_gsa, id_gga;
6
- VALUE id_start, id_continue, id_finish;
7
- VALUE id_manual, id_automatic, id_no_fix, id_2d, id_3d;
8
-
9
- int load_constants() {
10
- if(!rb_const_defined(rb_cObject, id_GPS)) return 0;
11
- mGPS = rb_const_get(rb_cObject, rb_intern("GPS"));
12
- if(!rb_const_defined(mGPS, id_Latitude)) return 0;
13
- cLatitude = rb_const_get(mGPS, rb_intern("Latitude"));
14
- if(!rb_const_defined(mGPS, id_Longitude)) return 0;
15
- cLongitude = rb_const_get(mGPS, rb_intern("Longitude"));
16
- return 1;
17
- }
18
-
19
- /*
20
- * Usage: NMEA::scan(nmea_sentence, handler)
21
- */
22
- static VALUE scan(VALUE self, VALUE sentence, VALUE handler) {
23
- Check_Type(sentence, T_STRING);
24
- nmea_scanner(RSTRING(sentence)->ptr, handler);
25
- return Qnil;
26
- }
27
-
28
-
29
-
30
- void Init_nmea() {
31
- id_GPS = rb_intern("GPS");
32
- id_Latitude = rb_intern("Latitude");
33
- id_Longitude = rb_intern("Longitude");
34
- id_new = rb_intern("new");
35
- id_rmc = rb_intern("rmc");
36
- id_gsv = rb_intern("gsv");
37
- id_start = ID2SYM(rb_intern("start"));
38
- id_continue = ID2SYM(rb_intern("continue"));
39
- id_finish = ID2SYM(rb_intern("finish"));
40
- id_gsa = rb_intern("gsa");
41
- id_manual = ID2SYM(rb_intern("manual"));
42
- id_automatic = ID2SYM(rb_intern("automatic"));
43
- id_no_fix = ID2SYM(rb_intern("no_fix"));
44
- id_2d = ID2SYM(rb_intern("gps_2d"));
45
- id_3d = ID2SYM(rb_intern("gps_3d"));
46
- id_gga = rb_intern("gga");
47
- cLatitude = Qnil;
48
- cLongitude = Qnil;
49
- cTime = rb_const_get(rb_cObject, rb_intern("Time"));
50
- /*
51
- * Document-module: NMEA
52
- * NMEA module has the only method: scan. Better read about it.
53
- */
54
- mNMEA = rb_define_module("NMEA");
55
- rb_define_singleton_method(mNMEA, "scan", scan, 2);
56
- /*
57
- * Document-class: NMEA::ParseError
58
- * You will receive ParseError if NMEA::scan cannot parse sentence. Usually it happens, when
59
- * you try to parse broken sentence. Perhaps, through it away.
60
- */
61
- eParseError = rb_define_class_under(mNMEA, "ParseError", rb_eStandardError);
62
- cSatelliteInfo = rb_struct_define(NULL, "number", "elevation", "azimuth", "signal_level", NULL);
63
- /* Struct.new(:number, :elevation, :azimuth, :signal_level): assigned to SatelliteInfo */
64
- rb_define_const(mNMEA, "SatelliteInfo", cSatelliteInfo);
65
- }