line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::MindWave::Packet::Parser; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
131
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
96
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
2451
|
use Device::MindWave::Packet::Dongle::HeadsetFound; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
116
|
|
7
|
4
|
|
|
4
|
|
2454
|
use Device::MindWave::Packet::Dongle::HeadsetNotFound; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
98
|
|
8
|
4
|
|
|
4
|
|
2360
|
use Device::MindWave::Packet::Dongle::HeadsetDisconnected; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
105
|
|
9
|
4
|
|
|
4
|
|
2296
|
use Device::MindWave::Packet::Dongle::RequestDenied; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
102
|
|
10
|
4
|
|
|
4
|
|
2360
|
use Device::MindWave::Packet::Dongle::StandbyMode; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
96
|
|
11
|
4
|
|
|
4
|
|
2451
|
use Device::MindWave::Packet::Dongle::ScanMode; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
106
|
|
12
|
4
|
|
|
4
|
|
2187
|
use Device::MindWave::Packet::ThinkGear; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
840
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %PACKET_MAP = ( |
15
|
|
|
|
|
|
|
'HeadsetFound' => [ 0xD0 ], |
16
|
|
|
|
|
|
|
'HeadsetNotFound' => [ 0xD1 ], |
17
|
|
|
|
|
|
|
'HeadsetDisconnected' => [ 0xD2 ], |
18
|
|
|
|
|
|
|
'RequestDenied' => [ 0xD3 ], |
19
|
|
|
|
|
|
|
'StandbyMode' => [ 0xD4, 0x01, 0x00 ], |
20
|
|
|
|
|
|
|
'ScanMode' => [ 0xD4, 0x01, 0x01 ], |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new |
24
|
|
|
|
|
|
|
{ |
25
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
26
|
3
|
|
|
|
|
8
|
my $self = {}; |
27
|
3
|
|
|
|
|
11
|
bless $self, $class; |
28
|
3
|
|
|
|
|
24
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub parse |
32
|
|
|
|
|
|
|
{ |
33
|
89
|
|
|
89
|
1
|
119
|
my ($self, $bytes) = @_; |
34
|
|
|
|
|
|
|
|
35
|
89
|
|
|
|
|
290
|
PACKET: for my $packet (keys %PACKET_MAP) { |
36
|
198
|
|
|
|
|
249
|
my $match_bytes = $PACKET_MAP{$packet}; |
37
|
198
|
|
|
|
|
232
|
for (my $i = 0; $i < @{$match_bytes}; $i++) { |
|
465
|
|
|
|
|
1062
|
|
38
|
380
|
100
|
|
|
|
789
|
if ($bytes->[$i] != $match_bytes->[$i]) { |
39
|
113
|
|
|
|
|
393
|
next PACKET; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
85
|
|
|
|
|
160
|
my $pkg = "Device::MindWave::Packet::Dongle::".$packet; |
43
|
85
|
|
|
|
|
308
|
return $pkg->new($bytes, 0); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
39
|
return Device::MindWave::Packet::ThinkGear->new($bytes, 0); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |