Jap, so sollte es stimmen.
Wo ich schon dabei bin, hier mal kurz meine Version:
Delphi-Quellcode:
type
TRequestType = record
Recipient: Byte;
Reserved: Byte;
Typ: Byte;
Dir: Boolean;
end;
implementation
function DecodeRequestType(ARequestType: Byte): TRequestType;
begin
With Result do
begin
Recipient := (ARequestType shr 6) and 3;
Reserved := (ARequestType shr 3) and 7;
Typ := (ARequestType shr 1) and 3;
Dir := (ARequestType and 1) > 0;
end;
end;
// Ggf. zusätzlich: function EncodeRequestType(ARequestType: TRequestType): Byte;
procedure TForm1.Button1Click(Sender: TObject);
var
LRequestType: TRequestType;
begin
LRequestType := DecodeRequestType( { Wert holen } );
ShowMessageFmt('Recipient = %d, Reserved = %d, Type = %d, Dir = %d',
[LRequestType.Recipient, LRequestType.Reserved, LRequestType.Typ, Ord(LRequestType .Dir)]);
end;