ТЕЛЕФОНИЯ
и
i: integer;
'
toevoegen: boolean;
ip; string;
ipadd: boolean;
nietantwoorden: boolean;
voegnaamtoe: boolean;
begin
if nuraberbytes > 70 then exit;
if numberbytes > 30 then nznping.ReadBuffer(a, numberbytes)
else exit;
s:=s
toevoegen := False;
nietantwoorden :* False;
i : = 1,-
ipadd := False;
ip:*
naam
:* "";
voegnaamtoe ;= False;
while i
<—
numberbytes do
begin
if e[i) *
then voegnaamtoe ;* False;
if voegnaamtoe then naam
:* naam
+ a[i];
if a[i] = "I" then ipadd :* True;
if ((a[i| < "0") or (a[i] > "9")) end (a[i] o ".") and (a[i] o "i")
then
ipadd :* False;
if (a[i] <> "I") and ipsdd then ip :* ip + a[i];
if (a[i] < "0") or (a[i] > "9") then
begin
toevoegen := False
end;
if toevoegen then s ;* s + a[i];
if a[i] * "Q" then toevoegen :» True;
if s[i] *
then nietantwoorden := True;
if a[i] = "M" then voegnaam
toe := True;
i ;* i + 1
end;
if assigned(fpingevent) then fpingevent(Sender, a, nietantwoorden, ip,
port, naam);
if fpingrespond and (not nietantwoorden) then
begin
if trim(s) o "" then
try
fpingreroote := StrToInt(a);
nmping.Remote Port := StrToInt(s);
nmping.RemoteHost :* ip;
if trim(flocalip) * "" then ips;
s := "I" + flocalip + "P" + IntToStr(flocal) + "V" +
intToStr(Ord(fverbinding)) +
+ "Q" + IntToStr(fpingremote);
if factive then s :« s + "AT"
else
s : = s + "AF";
if fanswer then s :* s + "OT"
else
s :* s + "OF";
s :* s + "@";
for x :* 1 to length(s) do a[i) :® s[i];
nmping.SendBuf£er(a, 60);
except
end
end
end;
procedure Tipt,NMDataReceivedd4(Sender; TCoaponent;
NuraberBytes: integer; Fram
lP: string);
begin
nmdatareceived (Sender, nuraberbytes, fromip, fport)
end;
procedure Tipt.nmDataReceived(Sender: TCcmponent; NumberBytes: integer;
From
ip: string; Port: integer);
var
s: string;
k: tmemorystream;
p: pointer;
groot: integer;
h: boolean;
begin
try //ofipadoTxa OTcyrcTmca K
imeHTa-*
k: = Tmemorystream.Create; k.Clear;
try
nm.ReadStream(k) ;
if nuraberbytes * roessagesize then begin
setlength(s, messagesize);
k.Read(s[l], messagesize);
s:= trim(s) ;
if (trim(s)[1] O "I") then begin
if length(s) > 2 then if (s[l) = "6") and (s[2J ■ ”4") then Delete(s,
1,2);
showbericht(s)
end else begin
beller(s);
if fanswer then begin
active:* Trua;
sencbnessage ("Aconnected.
. . ");
ftimer.Enabled:* False
end;
if assigned(fcalled) then fcalled(Sender, s);
end
end else begin
h:* False;
if assigned(fbeforesoundout) then begin
getmem(p, k.size);
move(k .memory'-, pA, k.size);
groot:* k.size;
fbeforesoundout(p, groot, h);
if h then
try acmoutl.play(p, groot); finally freemem(p) end;
freemem (p)
end;
if (not h) and ((random(1200) > fsyncfactor) or (not fsync)) then
acmoutl.Play(k.memory, k.size);
if assigned(fsoundrecieved) then fsoundrecieved(self, fromip);
end;
finally
k.Clear;
k.Free
end except end
end;
4) работа с модемом:
function upmodem(port,corner:string; p,aode:boolean):boolean;
var nabor: string;
NumberWritten: cardinal;
begin
result;* true;
hFile:* CreateFile(PChar(uppercase(port)),
GENERICJHRITE, 0, ni 1, OPEN__EXISTING
, FILE_ATTR
IBUTE__NORMAL, 0) ;
if hFile*INVALID_KANDLE_WLUE then begin
result:* false; exit end;
//поднятые и набор-
if mode then nabor:* "ATDT "+ nomer +
#13 + #10 + "ATH1"+ #13 +
• #10
else nabor:* "ATDP "+ nomer +
• ";"+ #13 +
• #10 + "ATH1'4 #13 + #10;
if not p then nabor:* "АТВ0";
//передача-
NumberWritten:* 0;
result:* HriteFile(hFile, PChar(nabor)A,
Length(nabor),
NumberWritten,nil);
CloseHandle(hFile)
end;
function readmodem(port:string):string;
var NumberWritten: cardinal;
begin
result:* "Open "+ port;
//
hFile:* CreateFile(PChar(uppercase(port)),
GENER
IC_FEAD
,0,nil,OPENJ2XISTING
,FILE_ATTRIBUTE_NOSMAL,0);
if hFile*INVALID_HANDLE_VALUE then begin
result:*'NOT read ‘4 port;
exit
end
end;
function getstatus(port:string):string;
var Modemstat: DWord;
begin
result:* "nil":
hFile:* CreateFile(PChar(uppercase(port)),
GENER
IC_WR
ITE,0,ni1,OPENJEXISTING
,FILE_ATTRIBUTE_NORMAL,0);
if hFile*INVALID_HANDLE_VALDE then exit;
//
if GetCcemModemStatus(hFile, Modemstat) О false then begin
if Modemstat and MS_CTS_ON
<> 0 then result:* "CTS";
if ModemStat and MS_DSR
ON
О 0 then result:* "DSR";
if ModemS
tat and MS__R
ING_0N
О 0 then result:* "RING";
if ModemStat and MSJRLSDJ0N
О 0 then result:* "RLSD"
end;
CloseHandle(hFile)
end;
5) передача служебных сообщений:
procedure Tipt.sencbnessage (s: string)
var k: tmemorystream;
begin
if factive then begin
s : * ” Ь
&" + s + " @
;
к := tmemorystream.Create;
if length(s) < messagesize then
try
k.SetSize(messagesize);
setlength(s, messagesize);
k.Write(s[1J, length(s));
nm.Sendstream(k);
finally k.Clear;
к.Free
end
end
end;
Ш
[] Радиолюбитель - 0 7 /2 0 0 8
предыдущая страница 56 Радиолюбитель 2008-07 читать онлайн следующая страница 58 Радиолюбитель 2008-07 читать онлайн Домой Выключить/включить текст