funtionunit.~pas

来自「***智能监视系统*** 程序运行时需要视频捕捉设备」· ~PAS 代码 · 共 65 行

~PAS
65
字号
unit FuntionUnit;

interface
var
    Port: smallint;
    Speed: integer;
    DataBit:smallint;
    Check:string;
    Stop:string;
    
procedure CalCheck(var BA : array of byte);
procedure Ept(var BA: array of byte);
procedure AntiEpt(var BA: array of byte);

implementation

//计算校验位
procedure CalCheck(var BA : array of byte);
var
    i:smallint;
    mTotal:integer;
begin
    //断言数据位数
    Assert(Length(BA)=8,'The Length is NOT Correct!');
    mTotal := $13;
    for i:=0 to 6 do
    begin
        mTotal := mTotal + BA[i];
    end;
    BA[7] := mTotal mod $ff;
end;

//加密数据
procedure Ept(var BA: array of byte);
var
    i:smallint;
    mTmp:byte;
begin
    //断言数据位数
    Assert(Length(BA)=8,'The Length is NOT Correct!');
    mTmp := $2a;
    for i:=5 downto 1 do
    begin
        BA[i] := BA[i-1] xor BA[i];
    end;
    BA[0] := BA[5] xor $2a;

end;

procedure AntiEpt(var BA: array of byte);
var
    i:smallint;
    mTmp:byte;
begin
    //断言数据位数
    Assert(Length(BA)=8,'The Length is NOT Correct!');
    BA[0] := $2a xor BA[5];
    for i:=1 to 5 do
    begin
        BA[i] := BA[i-1] xor BA[i];
    end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?