Registriert seit: 22. Sep 2006
57 Beiträge
|
Re: Comport und LED Lauflicht
27. Apr 2008, 12:07
Hier nochmal:
Delphi-Quellcode:
Const
LedHeader = '$CST-ES';
Address = ?; '? = Integerwert
Version = ?; '? = Integerwert
SignW = ?; '? = Integerwert
SignH = ?; '? = Integerwert
SignC = ?; '? = Integerwert
Reserved := '00000';
function SchnuerePaket(Sendestring: String): String;
var
Laenge: Integer;
Highnibbel, Lownibbel: Byte;
HighAddress, LowAddress: Byte;
HighSignW, LowSignW: Byte;
Checksumme: Integer;
Check : String;
iIndex := Integer;
begin
Sendestring := chr($1) + chr($1) + chr($1) + chr($EF) + chr($A0) + chr($EF) + chr($B0) + Sendestring + chr($FF) + chr($FF);
Laenge := 2 + 1 + 2 + 1 + 1 + 5 + Length(Sendestring);
Highnibbel:= Laenge div 256;
Lownibbel:= Laenge mod 256;
HighAddress:= Address div 256;
LownAddress:= Address mod 256;
HighSignW:= SignW div 256;
LownSignW:= SignW mod 256;
Check := Chr(HighAddress) + Chr(LowAddress) + Chr(Version)
+ Chr(HighSignW) + Chr(LowSignW) + Chr(SignH) + Chr(SignC) + Reserved + Sendestring;
for iIndex := 1 to Length(Check) do
begin
Checksumme := Ord(MidStr(Check, iIndex ,1));
if Checksumme >= 256 then Checksumme := Checksumme - 256;
end;
result := LedHeader + Chr(Highnibbel) + Chr(Lownibbel) + Check + Chr(Checksumme);
end;
procedure Senden;
begin
ApdComPort1.PutString(SchnuerePacket('Hallo'));
end;
Wal
|
|
Zitat
|