quelqu'un peut m'aider à résoudre l'erreur (l'erreur c'est là CRC16(frame);

[dcc32 Erreur] modbus1.pas(102): E2010 Types incompatibles : 'string' et 'array[0..7] of Byte'

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 function CRC16(Data: string):byte;
var
  crc : word;
  i,j : Integer;
 
begin
  crc := $FFFF;
  for i := 1 to Length(Data) do begin
    crc := Ord(Data[i]) xor crc;
    for j := 1 to 8 do begin
      if (CRC and $01) = 1
        then CRC := (CRC shr 1) xor $A001
        else CRC := CRC shr 1;
    end;
  end;
  Result := crc;
 
end ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function Readcoils(address : byte; fct: byte; startadress: word; registers : longword  ) : byte;
 var
  CRC : array[0..1] of byte;
  frame : array[0..7] of byte;
 
  begin
            frame[0] := address;
            frame[1] := fct;
            frame[2] := (startadress shr 8);   
            frame[3] := startadress;
            frame[4] := (registers shr 8);   
            frame[5] := registers;
 
            CRC16(frame); 
            frame[length.frame - 2] := CRC[0];
            frame[length.frame - 1] := CRC[1];
            result := frame;
  end ;