| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Written by Travis Kent Beste |
|
3
|
|
|
|
|
|
|
# Fri Aug 6 14:26:05 CDT 2010 |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package BT368i; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
52605
|
use strict 'refs'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw( ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1776
|
use RingBuffer; |
|
|
1
|
|
|
|
|
3413
|
|
|
|
1
|
|
|
|
|
48
|
|
|
11
|
1
|
|
|
1
|
|
897
|
use BT368i::Serial; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
12
|
1
|
|
|
1
|
|
657
|
use BT368i::NMEA::GP::GSA; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
13
|
1
|
|
|
1
|
|
914
|
use BT368i::NMEA::GP::GLL; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
14
|
1
|
|
|
1
|
|
664
|
use BT368i::NMEA::GP::GGA; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
15
|
1
|
|
|
1
|
|
587
|
use BT368i::NMEA::GP::GSV; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
39
|
|
|
16
|
1
|
|
|
1
|
|
563
|
use BT368i::NMEA::GP::RMC; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
17
|
1
|
|
|
1
|
|
448
|
use BT368i::NMEA::GP::VTG; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
105
|
|
|
20
|
1
|
|
|
1
|
|
899
|
use IO::File; |
|
|
1
|
|
|
|
|
2318
|
|
|
|
1
|
|
|
|
|
585
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @ISA = qw(RingBuffer BT368i::Serial BT368i::NMEA::GP::RMC BT368i::NMEA::GP::GSA BT368i::NMEA::GP::GGA BT368i::NMEA::GP::GSV BT368i::NMEA::GP::GLL BT368i::NMEA::GP::VTG); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = sprintf("%d.%02d", q$Revision: 1.00 $ =~ /(\d+)\.(\d+)/); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------# |
|
27
|
|
|
|
|
|
|
# capture control-c |
|
28
|
|
|
|
|
|
|
#----------------------------------------# |
|
29
|
|
|
|
|
|
|
my $control_c_counter = 0; |
|
30
|
|
|
|
|
|
|
$SIG{INT} = \&my_control_c; |
|
31
|
|
|
|
|
|
|
sub my_control_c { |
|
32
|
0
|
|
|
0
|
0
|
|
$SIG{INT} = \&my_control_c; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
print "finishing up..."; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$control_c_counter++; |
|
37
|
0
|
0
|
|
|
|
|
if ($control_c_counter == 1) { |
|
38
|
0
|
|
|
|
|
|
print "done\n"; |
|
39
|
0
|
|
|
|
|
|
exit(); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#----------------------------------------# |
|
44
|
|
|
|
|
|
|
# |
|
45
|
|
|
|
|
|
|
#----------------------------------------# |
|
46
|
|
|
|
|
|
|
sub new { |
|
47
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
48
|
0
|
|
|
|
|
|
my %args = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my %fields = ( |
|
51
|
|
|
|
|
|
|
log_fh => '', |
|
52
|
|
|
|
|
|
|
log_filename => '', |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
serial => '', |
|
55
|
|
|
|
|
|
|
serialport => $args{'Port'}, |
|
56
|
|
|
|
|
|
|
serialbaud => $args{'Baud'}, |
|
57
|
|
|
|
|
|
|
serialtimeout => 5, # 5 second timeout |
|
58
|
|
|
|
|
|
|
serialline => '', # the line that we're parsing, so it doesn't get lost |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
ringbuffer => '', |
|
61
|
|
|
|
|
|
|
ringbuffersize => 4096, |
|
62
|
|
|
|
|
|
|
verbose => 1, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $self = { |
|
66
|
|
|
|
|
|
|
%fields |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
0
|
|
|
|
|
|
bless $self, $class; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# initialize the ringbuffer |
|
71
|
0
|
|
|
|
|
|
my $buffer = []; |
|
72
|
0
|
|
|
|
|
|
my $ringsize = $self->{ringbuffersize}; |
|
73
|
0
|
|
|
|
|
|
my $overwrite = 0; |
|
74
|
0
|
|
|
|
|
|
my $printextendedinfo = 0; |
|
75
|
0
|
|
|
|
|
|
my $r = new RingBuffer( |
|
76
|
|
|
|
|
|
|
Buffer => $buffer, |
|
77
|
|
|
|
|
|
|
RingSize => $ringsize, |
|
78
|
|
|
|
|
|
|
Overwrite => $overwrite, |
|
79
|
|
|
|
|
|
|
PrintExtendedInfo => $printextendedinfo, |
|
80
|
|
|
|
|
|
|
); |
|
81
|
0
|
|
|
|
|
|
$r->ring_init(); |
|
82
|
0
|
|
|
|
|
|
$r->ring_clear(); |
|
83
|
0
|
|
|
|
|
|
$self->{ringbuffer} = $r; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# connect to serial port |
|
86
|
0
|
|
|
|
|
|
$self->connect(); |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#----------------------------------------# |
|
92
|
|
|
|
|
|
|
# |
|
93
|
|
|
|
|
|
|
#----------------------------------------# |
|
94
|
|
|
|
|
|
|
sub DESTROY { |
|
95
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ($self->{serial}) { |
|
98
|
0
|
0
|
|
|
|
|
$self->{serial}->close || die "failed to close serialport"; |
|
99
|
0
|
|
|
|
|
|
undef $self->{serial}; # frees memory back to perl |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
$self->SUPER::DESTROY if $self->can("SUPER::DESTROY"); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#----------------------------------------# |
|
106
|
|
|
|
|
|
|
# |
|
107
|
|
|
|
|
|
|
#----------------------------------------# |
|
108
|
|
|
|
|
|
|
sub log { |
|
109
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
110
|
0
|
|
|
|
|
|
my $filename = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# set the filename in the object |
|
113
|
0
|
|
|
|
|
|
$self->{log_filename} = $filename; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# create a new file handle object because the other objects use this and |
|
116
|
|
|
|
|
|
|
# they end up sharing the same handle if we use a glob |
|
117
|
0
|
|
|
|
|
|
my $fh = new IO::File->new; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# generic open and unbuffered I/O |
|
120
|
0
|
|
|
|
|
|
open($fh, ">" . $self->{log_filename}); |
|
121
|
0
|
|
|
|
|
|
select($fh), $| = 1; # set nonbuffered mode, gets the chars out NOW |
|
122
|
0
|
|
|
|
|
|
$self->{log_fh} = (*$fh); |
|
123
|
0
|
|
|
|
|
|
select(STDOUT); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#----------------------------------------# |
|
127
|
|
|
|
|
|
|
# |
|
128
|
|
|
|
|
|
|
#----------------------------------------# |
|
129
|
|
|
|
|
|
|
sub get_sentances { |
|
130
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $sentances = $self->BT368i::Serial::_readlines(); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# if we're logging, save data to filehandle |
|
135
|
0
|
0
|
|
|
|
|
if ($self->{log_fh}) { |
|
136
|
0
|
|
|
|
|
|
foreach my $sentance (@$sentances) { |
|
137
|
0
|
|
|
|
|
|
print { $self->{log_fh} } $sentance . "\n"; |
|
|
0
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return $sentances; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__ |