Rev 518 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 518 | Rev 599 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | #!/usr/bin/perl -w |
1 | #!/usr/bin/perl -w |
| - | 2 | ################################################ |
|
| - | 3 | # |
|
| - | 4 | # This file should not be edited for settings |
|
| - | 5 | # use settings.pl for that |
|
| - | 6 | # |
|
| - | 7 | # author: arune @ efnet |
|
| - | 8 | # |
|
| - | 9 | ################################################ |
|
| - | 10 | ||
| 2 | use IO::Socket; |
11 | use IO::Socket; |
| 3 | use integer; |
12 | use integer; |
| 4 | use threads; |
13 | use threads; |
| 5 | 14 | ||
| 6 | #for sending time msg: set to 1, else set to 0 |
15 | #for sending time msg: set to 1, else set to 0 |
| Line 8... | Line 17... | ||
| 8 | 17 | ||
| 9 | #for printing timestamps on printed messages: set to 1, else set to 0 |
18 | #for printing timestamps on printed messages: set to 1, else set to 0 |
| 10 | $timestamp = 1; |
19 | $timestamp = 1; |
| 11 | 20 | ||
| 12 | #define filters for id of messages, passed messages will be printed on stdout |
21 | #define filters for id of messages, passed messages will be printed on stdout |
| 13 | @acceptmask_ones = ( |
22 | @acceptmask_ones = (); |
| 14 | @acceptmask_zeros = ( |
23 | @acceptmask_zeros = (); |
| 15 | @denymask_ones = (); |
24 | @denymask_ones = (); |
| 16 | @denymask_zeros = (); |
25 | @denymask_zeros = (); |
| 17 | 26 | ||
| 18 | @input = (); |
27 | @input = (); |
| 19 | @output = (); |
28 | @output = (); |
| 20 | 29 | ||
| 21 | #define makros, when an input sting is sent on can this perl-script will send the corresponding output string |
- | |
| 22 | - | ||
| 23 | # Remote button 1 => desktoplamp toggle |
- | |
| 24 | push(@input , "PKT 0409000a 1 0 00 00 05 01"); |
- | |
| 25 | push(@output, "PKT 08008c00 1 0 03"); |
- | |
| 26 | - | ||
| 27 | # Remote button 4 down => blinds darker |
- | |
| 28 | push(@input , "PKT 0409000a 1 0 00 00 05 04"); |
- | |
| 29 | push(@output, "PKT 08010200 1 0 00 03"); |
- | |
| 30 | - | ||
| 31 |
|
30 | $host = "localhost"; |
| 32 | push(@input , "PKT 0409000a 1 0 0f 00 05 04"); |
- | |
| 33 | push(@output, "PKT 08010200 1 0 00 04"); |
- | |
| 34 | - | ||
| 35 | # Remote button 6 down => blinds lighter |
- | |
| 36 | push(@input , "PKT 0409000a 1 0 00 00 05 06"); |
- | |
| 37 |
|
31 | $port = 1200; |
| 38 | 32 | ||
| 39 |
|
33 | require "settings.pl"; |
| 40 | push(@input , "PKT 0409000a 1 0 0f 00 05 06"); |
- | |
| 41 | push(@output, "PKT 08010200 1 0 00 04"); |
- | |
| 42 | - | ||
| 43 | 34 | ||
| 44 | $remote = IO::Socket::INET->new( |
35 | $remote = IO::Socket::INET->new( |
| 45 | Proto => "tcp", |
36 | Proto => "tcp", |
| 46 | PeerAddr => |
37 | PeerAddr => $host, |
| 47 | PeerPort => |
38 | PeerPort => $port, |
| 48 | ) |
39 | ) |
| 49 | or die "cannot connect to port 1200 at localhost"; |
40 | or die "cannot connect to port 1200 at localhost"; |
| 50 | 41 | ||
| 51 | if ($sendtime == 1) { |
42 | if ($sendtime == 1) { |
| 52 | $thr = threads->new(\&sendTime); |
43 | $thr = threads->new(\&sendTime); |
| 53 | $thr->detach; |
44 | $thr->detach; |
| 54 | } |
45 | } |
| 55 | 46 | ||
| 56 | $acceptmask_ones = @acceptmask_ones; |
47 | $acceptmask_ones = @acceptmask_ones; |
| 57 | $acceptmask_zeros = @acceptmask_zeros; |
48 | $acceptmask_zeros = @acceptmask_zeros; |
| 58 | if ($acceptmask_ones != $acceptmask_zeros) { |
49 | if ($acceptmask_ones != $acceptmask_zeros) { |
| 59 | print "Acceptmasks must be same length\n"; |
50 | print "Acceptmasks must be same length\n"; |
| 60 | exit; |
51 | exit; |
| 61 | } |
52 | } |
| 62 | 53 | ||
| 63 | $denymask_ones = @denymask_ones; |
54 | $denymask_ones = @denymask_ones; |
| 64 | $denymask_zeros = @denymask_zeros; |
55 | $denymask_zeros = @denymask_zeros; |
| 65 | if ($denymask_ones != $denymask_zeros) { |
56 | if ($denymask_ones != $denymask_zeros) { |
| 66 | print "Denymasks must be same length\n"; |
57 | print "Denymasks must be same length\n"; |
| Line 116... | Line 107... | ||
| 116 | } |
107 | } |
| 117 | 108 | ||
| 118 | sub sendTime { |
109 | sub sendTime { |
| 119 | $remote = IO::Socket::INET->new( |
110 | $remote = IO::Socket::INET->new( |
| 120 | Proto => "tcp", |
111 | Proto => "tcp", |
| 121 | PeerAddr => |
112 | PeerAddr => $host, |
| 122 | PeerPort => |
113 | PeerPort => $port, |
| 123 | ) |
114 | ) |
| 124 | or die "cannot connect to port |
115 | or die "cannot connect to port $port at $host"; |
| 125 | 116 | ||
| 126 | while (1) { |
117 | while (1) { |
| 127 | select(undef, undef, undef, 0.5); |
118 | select(undef, undef, undef, 0.5); |
| 128 | print $remote "PKT 00000000 1 0"; |
119 | print $remote "PKT 00000000 1 0"; |
| 129 | } |
120 | } |