-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter
executable file
·187 lines (176 loc) · 3.85 KB
/
plotter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/perl -w
## http://paulbourke.net/dataformats/hpgl/
my $EOL = chr(3); # ";\r\n";
sub sendOut($)
{
my $s = shift;
print "$s", $EOL;
}
sub sendEsc($)
{
my $ch = shift;
sendOut(chr(27) . $ch);
}
my $cmds = {
'set-config' => {
'help' => 'Set Plotter Configuraiton', 'args' => undef, 'doit' => sub {
sendEsc('@');
},
},
'output-ident' => {
'help' => 'Output Identification', 'args' => undef, 'doit' => sub {
sendEsc('A');
},
},
'output-buffer-space' => {
'help' => 'Output Buffer Space', 'args' => undef, 'doit' => sub {
sendEsc('B');
},
},
'output-extended-error' => {
'help' => 'Output Extended error', 'args' => undef, 'doit' => sub {
sendEsc('E');
},
},
'set-handshake-mode-1' => {
'help' => 'Set Handshake Mode 1', 'args' => undef, 'doit' => sub {
sendEsc('H');
},
},
'set-handshake-mode-2' => {
'help' => 'Set Handshake Mode 2', 'args' => undef, 'doit' => sub {
sendEsc('I');
},
},
'abort-device-control' => {
'help' => 'Abort Device Control', 'args' => undef, 'doit' => sub {
sendEsc('J');
},
},
'abort-graphics' => {
'help' => 'Abort Graphics', 'args' => undef, 'doit' => sub {
sendEsc('K');
},
},
'output-buffer-size-when-empty' => {
'help' => 'Output Buffer Size When Empty', 'args' => undef, 'doit' => sub {
sendEsc('L');
},
},
'set-output-mode' => {
'help' => 'Set Output Mode', 'args' => undef, 'doit' => sub {
sendEsc('M');
},
},
'set-extended-output-and-handshake-mode' => {
'help' => 'Set Extended Output and Handshake Mode', 'args' => undef, 'doit' => sub {
sendEsc('N');
},
},
'output-extended-status' => {
'help' => 'Output Extended Status', 'args' => undef, 'doit' => sub {
sendEsc('O');
},
},
'set-handshake-mode' => {
'help' => 'Set Handshake Mode', 'args' => undef, 'doit' => sub {
sendEsc('P');
},
},
'set-monitor-mode' => {
'help' => 'Set Monitor Mode', 'args' => undef, 'doit' => sub {
sendEsc('Q');
},
},
'sp8' => {
'help' => 'Set Pen 8', 'args' => undef, 'doit' => sub {
sendOut('SP8');
},
},
'sp1' => {
'help' => 'Set Pen 1', 'args' => undef, 'doit' => sub {
sendOut('SP1');
},
},
'sp0' => {
'help' => 'Set Pen 0', 'args' => undef, 'doit' => sub {
sendOut('SP0');
},
},
'reset' => {
'help' => 'Reset', 'args' => undef, 'doit' => sub {
sendEsc('R');
sendEsc('A');
sendEsc('O');
sendOut('IN');
sendOut('SP0');
sendOut('PU');
sendOut('PA0,0');
sendOut('IN');
sendOut('SP1');
sleep(2);
sendOut('IN');
sendOut('SP0');
sendOut('IN');
sendEsc('R');
sendOut('IN');
},
},
'output-configurable-memory' => {
'help' => 'Output Configurable Memory', 'args' => undef, 'doit' => sub {
sendEsc('S');
},
},
'allocate-configurable-memory' => {
'help' => 'Allocate Configurable Memory', 'args' => undef, 'doit' => sub {
sendEsc('T');
},
},
'end-flush-mode' => {
'help' => 'End Flush Mode', 'args' => undef, 'doit' => sub {
sendEsc('U');
},
},
'plotter-on' => {
'help' => 'Plotter On', 'args' => undef, 'doit' => sub {
sendEsc('Y');
},
},
'plotter-on2' => {
'help' => 'Plotter On', 'args' => undef, 'doit' => sub {
sendEsc('(');
},
},
'plotter-off' => {
'help' => 'Plotter Off', 'args' => undef, 'doit' => sub {
sendEsc('Z');
},
},
'plotter-off2' => {
'help' => 'Plotter Off', 'args' => undef, 'doit' => sub {
sendEsc(')');
},
}
};
sub usage()
{
print "Plotter Control: plotter:3001", "\n";
foreach (sort keys %$cmds) {
my $cmd = $cmds->{$_};
my $val = $_ . ' ';
printf "\t--%s%s\n", substr($val, 0, 30), $cmd->{'help'};
}
exit(-1);
}
my (@todo);
foreach (@ARGV) {
if ($_ !~ m/\-\-(.*)$/ || ! defined ($cmds->{$1})) {
print "Unknown command $_ ($1)", "\n";
usage();
}
my $cmd = $cmds->{$1};
push (@todo, $cmd->{'doit'});
}
foreach (@todo) {
$_->();
}