| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Device::MegaSquirt; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1007
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
5
|
1
|
|
|
1
|
|
14
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
79
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
64
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
9
|
|
|
|
|
|
|
require 5.6.1; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
619
|
use Device::MegaSquirt::Serial; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Load all the version specific libraries (used by new()). |
|
15
|
1
|
|
|
1
|
|
732
|
use Device::MegaSquirt::MS2ExtraRel303s; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
390
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Device::MegaSquirt - Perl5 module for communicating with a MegaSquirt controller |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$dev = '/dev/ttyUSB0'; |
|
24
|
|
|
|
|
|
|
$ms = Device::MegaSquirt->new($dev); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$tbl = $ms->read_advanceTable1(); |
|
27
|
|
|
|
|
|
|
$tbl = $ms->write_advanceTable1(); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$tbl = $ms->read_veTable1(); |
|
30
|
|
|
|
|
|
|
$tbl = $ms->write_veTable1(); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$val = $ms->read_crankingRPM(); |
|
33
|
|
|
|
|
|
|
$res = $ms->write_crankingRPM($val); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$data = $ms->read_BurstMode(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$version = $ms->get_version(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Device::MegaSquirt provides operations for communicating with a MegaSquirt controller |
|
42
|
|
|
|
|
|
|
[http://www.msextra.com]. Operations such as reading/writing tables, |
|
43
|
|
|
|
|
|
|
reading live data, and writing configuration variables. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This part of the module (Device::MegaSquirt) is a template and version specific |
|
46
|
|
|
|
|
|
|
modules (Device::MegaSquirt::*) implement the interface. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 OPERATIONS |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# {{{ new() :-) |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 Device::MegaSquirt->new($dev); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns object (TRUE) on success, FALSE on error |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$ms = Device::MegaSquirt->new($dev); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The device ($dev) is the file name of the serial device on which |
|
61
|
|
|
|
|
|
|
the Megasquirt controller is connected (e.g.: /dev/ttyUSB0, /dev/ttyS0). |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
C will attempt to open the device and determine the version and |
|
64
|
|
|
|
|
|
|
signature of the controller. It will return a version specific |
|
65
|
|
|
|
|
|
|
object on success. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
|
70
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
71
|
0
|
|
|
|
|
|
my $dev = shift; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $mss = Device::MegaSquirt::Serial->new($dev); |
|
74
|
0
|
0
|
|
|
|
|
unless ($mss) { |
|
75
|
0
|
|
|
|
|
|
carp "ERROR: unable to create Device::MegaSquirt::Serial object."; |
|
76
|
0
|
|
|
|
|
|
return; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $version = $mss->read_Q(); |
|
80
|
0
|
0
|
|
|
|
|
unless ($version) { |
|
81
|
0
|
|
|
|
|
|
carp "ERROR: unable to read version"; |
|
82
|
0
|
|
|
|
|
|
return; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $signature = $mss->read_S(); |
|
86
|
0
|
0
|
|
|
|
|
unless ($signature) { |
|
87
|
0
|
|
|
|
|
|
carp "ERROR: unable to read signature"; |
|
88
|
0
|
|
|
|
|
|
return; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Create a version specific object |
|
92
|
0
|
|
|
|
|
|
my $obj; |
|
93
|
0
|
0
|
|
|
|
|
if ($version =~ /^[\s\0]*MS2Extra Rel 3.0.3s[\s\0]*$/) { |
|
94
|
0
|
|
|
|
|
|
$obj = Device::MegaSquirt::MS2ExtraRel303s->new($mss); |
|
95
|
|
|
|
|
|
|
} else { |
|
96
|
0
|
|
|
|
|
|
carp "Unknown version: '$version'\n"; |
|
97
|
0
|
|
|
|
|
|
return; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$obj->{version} = $version; |
|
101
|
0
|
|
|
|
|
|
$obj->{signature} = $signature; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $obj; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# }}} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# {{{ get_version() |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 $ms->get_version() |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns: version number on success, FALSE on error |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$version = $ms->get_version(); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub get_version { |
|
120
|
0
|
|
|
0
|
1
|
|
$_[0]->{version}; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# }}} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# {{{ get_mss :-) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub get_mss { |
|
128
|
0
|
|
|
0
|
0
|
|
$_[0]->{mss}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# }}} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Remaining operations are implemented in the version specific module. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Device::MegaSquirt::* |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 VERSION |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This document refers to Device::MegaSquirt version 0.01. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 REFERENCES |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
[1] MegaSquirt Engine Management System |
|
148
|
|
|
|
|
|
|
http://www.msextra.com/ |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Jeremiah Mahler |
|
153
|
|
|
|
|
|
|
CPAN ID: JERI |
|
154
|
|
|
|
|
|
|
http://www.google.com/profiles/jmmahler#about |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (c) 2010, Jeremiah Mahler. All Rights Reserved. |
|
159
|
|
|
|
|
|
|
This module is free software. It may be used, redistributed |
|
160
|
|
|
|
|
|
|
and/or modified under the same terms as Perl itself. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Text::LookUpTable, Device::MegaSquirt::Serial |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |