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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
{$A-,H+}
unit mainform;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,zlportio, ComCtrls, shellapi,rdtsc;
type
TMain = class(TForm)
lb1: TLabel;
ePort: TEdit;
lb2: TLabel;
eData: TEdit;
eRData: TEdit;
btnExit: TButton;
lb3: TLabel;
coDataType: TComboBox;
Lb4: TLabel;
gb1: TGroupBox;
sbBar: TStatusBar;
lb5: TLabel;
btnWrite: TButton;
btnRead: TButton;
cbDirect: TCheckBox;
llbWWW: TLabel;
procedure btnExitClick(Sender: TObject);
procedure ePortKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ePortKeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure coDataTypeChange(Sender: TObject);
procedure ePortKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnWriteClick(Sender: TObject);
procedure eDataKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnReadClick(Sender: TObject);
procedure cbDirectClick(Sender: TObject);
procedure llbWWWClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure setrdata(const Data:dword);
function str2int(const value:string;const HEX:boolean):integer;
end;
var
Main: TMain;
implementation
{$R *.DFM}
{$R-}
function TMain.str2int(const value:string;const HEX:boolean):integer;
begin
if HEX then
result := strtoint('$' + value)
else
result := strtoint(value);
end;
procedure TMain.btnExitClick(Sender: TObject);
begin
close;
end;
procedure TMain.ePortKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
try
Case key of
38: begin
key := 0;
end;
40: begin
key := 0;
end
end;
except
end;
end;
procedure TMain.ePortKeyPress(Sender: TObject; var Key: Char);
begin
// filter on hex
if pos(key,#13#8'0123456789abcdefABCDEF')=0 then
key := #0;
end;
procedure TMain.FormCreate(Sender: TObject);
begin
coDataType.itemindex :=0;
coDataType.Tag := 2;
if ZLIOStarted then
sbBar.SimpleText := 'Driver successfully started !'
else
sbBar.SimpleText := 'Couldnt start driver. Something wrong !';
end;
procedure TMain.coDataTypeChange(Sender: TObject);
var s:string;
begin
coDataType.Tag := 2 shl (coDataType.itemindex);
erdata.MaxLength := coDataType.Tag;
edata.MaxLength := coDataType.Tag;
s := edata.Text;
delete(s,1,length(s)-coDataType.Tag);
edata.text := s;
end;
procedure TMain.ePortKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var Port,data:dword;
begin
try
try
Port := str2int(ePort.Text,true);
except
Port := 0;
end;
Case key of
13: begin
zlioportwrite(port,coDataType.itemindex,str2int(eData.Text, true));
end;
38: begin
inc(Port);
ePort.Text := inttohex(Port,3);
key := 0;
end;
40: begin
if port > 0 then
dec(Port);
ePort.Text := inttohex(Port,3);
key := 0;
end
end;
setthreadpriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
data := zlioportread(Port,coDataType.itemindex);
setrdata(data);
except
end;
end;
procedure TMain.setrdata(const Data:dword);
begin
erData.Text := inttohex(Data,coDataType.Tag);
end;
procedure TMain.btnWriteClick(Sender: TObject);
var i:word;
begin
i := 13;
ePortKeyDown( self,i,[])
end;
procedure TMain.eDataKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var data:dword;
begin
try
Data := str2int(eData.Text,true);
except Data := 0; end;
Case key of
13: begin
ePortKeyDown( self,key,[])
end;
38: begin
inc(Data);
eData.Text := inttohex(Data,coDataType.Tag);
key := 0;
end;
40: begin
dec(Data);
eData.Text := inttohex(Data,coDataType.Tag);
key := 0;
end
end;
end;
procedure TMain.btnReadClick(Sender: TObject);
var k:word;
begin
k := 0;
ePortKeyDown(self, k,[]);
end;
procedure TMain.cbDirectClick(Sender: TObject);
begin
zliosetiopm(cbDirect.Checked);
end;
procedure TMain.llbWWWClick(Sender: TObject);
begin
shellexecute( 0,'open','http://www.specosoft.com/update/portio_15.htm',nil,nil,SW_SHOW);
end;
end.
|