[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
This is an ECO_LIB using, shining example on how to use EMSI, whilst
calling.
Receiving part is being written.
procedure putemsi;
var
i : byte;
ch : char;
res : string;
pp : word;
pack : ar1024;
begin
writeln('. Writing EMSI-enquiry...');
if debugmode then __logapp('Writing EMSI-enquiry...');
__clr1024(pack); __app1024(pack, emsi_inq + #13); send1024(pack);
__clr1024(pack);
__app1024(pack, 'EMSI_DAT');
__app1024(pack, length_emsi_dat);
__app1024(pack, emsi_dat);
crc := hex(crc16(pack));
__clr1024(pack);
__app1024(pack, '**EMSI_DAT');
__app1024(pack, length_emsi_dat);
__app1024(pack, emsi_dat);
__app1024(pack, crc + #13);
send1024(pack);
comwait;
repeat
inc(tries); res := '';
while (
comreceive(ch) and not(pos(emsi_req, __up(res)) > 0)
) do begin
res := res + ch; delay(12);
if debugmode then write(ch);
capturewrite(ch);
ch := #00;
end;
until (pos(emsi_req, __up(res)) > 0) or (tries = maxemsitries);
if res <> '' then __logapp('Response to inquiry: ' + res);
if (pos(emsi_req, __up(res)) > 0) then begin
res := '';
if debugmode then begin
writeln('. Yonder site has acknowledged receipt of EMSI_INQ');
__logapp('Yonder site has acknowledged receipt of EMSI_INQ');
end;
end else begin
writeln('! Host system failed to acknowledge the inquiry sequence.');
__logapp('Host system failed to acknowledge the inquiry sequence.');
if fossil then fos_hangup_(comport) else hangup232; __eos;
{ send_modem_command(modem_hang_up); absorb232response(false, tmp); }
end;
writeln('. Sending EMSI data...');
if debugmode then __logapp('Sending EMSI data...');
tries := 0;
__clr1024(pack); __app1024(pack, emsi_inq + #13); send1024(pack);
__clr1024(pack); __app1024(pack, 'EMSI_DAT'); __app1024(pack, length_emsi_dat);
__app1024(pack, emsi_dat); crc := hex(crc16(pack));
__clr1024(pack); __app1024(pack, '**EMSI_DAT');
__app1024(pack, length_emsi_dat); __app1024(pack, emsi_dat);
__app1024(pack, crc + #13); send1024(pack);
comwait;
repeat
inc(tries); res := ''; ch := #00;
while comreceive(ch) and (ch <> '*') do begin
if debugmode then write(ch); capturewrite(ch);
end;
ch := '*'; res := '*';
comwait;
while (
comreceive(ch) and not(pos(emsi_ack, __up(res)) > 0)
) do begin
res := addtolast20(res, ch); delay(12);
if debugmode then write(ch);
capturewrite(ch);
ch := #00;
end;
until (pos(emsi_ack, __up(res)) > 0) or (tries >= maxemsitries);
if (res <> '') then __logapp('Response to EMSI data (Acq?): ' + res);
if tries >= maxemsitries then begin
writeln('Host system failed to acknowledge the EMSI_DAT packet.');
__logapp('Host system failed to acknowledge the EMSI_DAT packet.');
if fossil then fos_hangup_(comport) else hangup232; __eos;
end else begin
writeln('. Boss has acknowledged receipt of EMSI_DAT');
__logapp('Boss has acknowledged receipt of EMSI_DAT');
end;
temp := '*'; { read in '**EMSI_DAT' }
repeat comreceive(ch); capturewrite(ch) until (ch = '*');
repeat
if comreceive(ch) then temp := temp + ch;
capturewrite(ch);
until(pos('**EMSI_DAT', temp) > 0);
pp := 8; { no '**' }
pack[1] := 'E'; pack[2] := 'M'; pack[3] := 'S'; pack[4] := 'I';
pack[5] := '_'; pack[6] := 'D'; pack[7] := 'A'; pack[8] := 'T';
len := ''; { read in the length }
for loop := 1 to 4 do begin
delay(12); if comreceive(ch) then len := len + ch;
inc(pp); pack[pp] := ch; capturewrite(ch);
end;
len_rec_emsi_dat := hex2dec(len);
if debugmode then begin
writeln('Length of DAT: (', len, ') ', len_rec_emsi_dat, '.');
__logapp('Length of DAT: (' + len + ') ' + __num(len_rec_emsi_dat) + '.');
end;
packet := '';
for loop := 1 to len_rec_emsi_dat do begin { read in the packet }
delay(12); comreceive(ch); inc(pp); pack[pp] := ch; capturewrite(ch);
end;
crc := ''; { read in the crc }
for loop := 1 to 4 do begin
delay(12); comreceive(ch); crc := crc + ch; capturewrite(ch);
end;
if hex(crc16(pack)) <> crc then begin
writeln('! The recieved EMSI_DAT is corrupt!!!!');
__logapp('The recieved EMSI_DAT is corrupt!!!!');
end;
__clr1024(pack); __app1024(pack, emsi_ack + #13); send1024(pack);
end; { EMSI mode }
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson