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:
| Function ExiScan(exiport: integer): integer;
var ExiSBuf: TIdBytes; ExiRBuffer: TIdBytes; ExiRet: Integer; Exi: TidBytes; y,i: Integer;
Begin
SetLength(ExiSBuf, 6); FillBytes(ExiSBuf, 6, 0); SetLength(ExiRBuffer, 11); FillBytes(ExiRBuffer, 11, 0); SetLength(Exi, 9); FillBytes(Exi, 9, 0);
y:=0; For i := exiport to 27 do Begin y:=y+1; ExiSBuf[0] := $23; ExiSBuf[1] := HexToByte(IntToHex(i,1)); ExiSBuf[2] := $0b; ExiSBuf[3] := $02; ExiSBuf[4] := $49; ExiSBuf[5] := $49; Exi[0] := $23; Exi[1] := $0B; Exi[2] := HexToByte(IntToHex(i,1)); Exi[3] := $07; Exi[4] := $05; Exi[5] := $00; Exi[6] := HexToByte(IntToHex(i,1)); Exi[7] := $02; Exi[8] := HexToByte(IntToStr(y));
Form4.IdUDPClient1.Sendbuffer(IP, strtoint(Form4.Edit2.Text), ExiSBuf);
Sleep(25); ExiRet := Form4.IdUDPClient1.ReceiveBuffer(ExiRBuffer,Sizeof(ExiRBuffer));
if ExiRet > 0 then begin SetLength(ExiRBuffer, ExiRet -2); if not ByteArrayPos(Exi, ExiRBuffer) = 0 then else Form4.Memo1.lines.add('Exi '+IntToStr(Exi[8])+' at adr: '+IntToStr(Exi[2])); Result := Exi[8]; end;
end;
end; |