program test;
{$MODE DELPHI}
uses
SysUtils;
function CalcCRC(Data: string): string;
var
CRC: byte;
i: integer;
begin
CRC := 255;
for i := 1 to Length(Data) do
CRC := CRC xor byte(Data[i]);
Result := IntToHex(CRC, 2);
end;
var
Data : string;
begin
Data := '1;0$e21S&0D28.29/28.29/';
Data := StringReplace(Data, '&0D', #13, [rfReplaceAll]);
Writeln(#27 + 'P' + Data + CalcCRC(Data) + #27 + '\');
end.
cHJvZ3JhbSB0ZXN0OwogCnskTU9ERSBERUxQSEl9CiAKdXNlcwogIFN5c1V0aWxzOwogCmZ1bmN0aW9uIENhbGNDUkMoRGF0YTogc3RyaW5nKTogc3RyaW5nOwp2YXIKICBDUkM6IGJ5dGU7CiAgaTogaW50ZWdlcjsKYmVnaW4KICBDUkMgOj0gMjU1OwogIGZvciBpIDo9IDEgdG8gTGVuZ3RoKERhdGEpIGRvCiAgICBDUkMgOj0gQ1JDIHhvciBieXRlKERhdGFbaV0pOwogIFJlc3VsdCA6PSBJbnRUb0hleChDUkMsIDIpOwplbmQ7CiAKdmFyCiAgRGF0YSA6IHN0cmluZzsKYmVnaW4KICBEYXRhIDo9ICcxOzAkZTIxUyYwRDI4LjI5LzI4LjI5Lyc7CiAgRGF0YSA6PSBTdHJpbmdSZXBsYWNlKERhdGEsICcmMEQnLCAjMTMsIFtyZlJlcGxhY2VBbGxdKTsKICBXcml0ZWxuKCMyNyArICdQJyArIERhdGEgKyBDYWxjQ1JDKERhdGEpICsgIzI3ICsgJ1wnKTsKZW5kLg==