Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Brauche mal Hilfe von einen C++ Spezi (https://www.delphipraxis.net/148357-brauche-mal-hilfe-von-einen-c-spezi.html)

ATS3788 28. Feb 2010 12:05


Brauche mal Hilfe von einen C++ Spezi
 
Code:
typedef struct
{
   unsigned char    packType;
   unsigned char    trackNumber;
   unsigned char    sequenceNumber;

   unsigned char    characterPosition   :4;
   unsigned char    block         :3;
   unsigned char    bDBC         :1;

   unsigned char    data[12];
   unsigned char    crc0;
   unsigned char    crc1;
}
cdTextPackage;
Kann mir das bitte einer ,von C++, nach
Pascal überstzen und wiviel bytes benutzt werden.

Danke

himitsu 28. Feb 2010 12:23

Re: Brauche mal Hilfe von einen C++ Spezi
 
Delphi-Quellcode:
type cdTextPackage = {packed} record
  packType: Byte;
  trackNumber: Byte;
  sequenceNumber: Byte;
  X: Set of (dummy0, bDBC, dummy2, block, characterPosition);
  //X: Set of ({ dummy = 0, } bDBC = 1, block = 3, characterPosition = 4);
  data: Array [0..11] of Byte;
  crc0: Byte;
  crc1: Byte;
end;
[...] = ein statisches Array
:X = ein Bit-Feld (dafür gibt es in Pascal keine wirkliche Entsprechnung)

zeras 28. Feb 2010 12:25

Re: Brauche mal Hilfe von einen C++ Spezi
 
Zitat:

Zitat von ATS3788
Code:
typedef struct
{
1   unsigned char    packType;
1   unsigned char    trackNumber;
1   unsigned char    sequenceNumber;

   unsigned char    characterPosition   :4;
   unsigned char    block         :3;
   unsigned char    bDBC         :1;
zusammen 1

   unsigned char    data[12];
12
1   unsigned char    crc0;
1   unsigned char    crc1;
}
cdTextPackage;
Kann mir das bitte einer ,von C++, nach
Pascal überstzen und wiviel bytes benutzt werden.

Danke

Ich bin zwar auch nicht der Experte, aber das müßte wie oben beschrieben sein.

ATS3788 28. Feb 2010 21:10

Re: Brauche mal Hilfe von einen C++ Spezi
 
Ihr seit toll Danke. :angel:
Admin wie schließe ich ein Thema?

Muetze1 28. Feb 2010 23:35

Re: Brauche mal Hilfe von einen C++ Spezi
 
1. seid (www.seit-seid.de)
2. Themen werden nicht geschlossen
3. Die Übersetzung ist falsch.

Zu 3.: das Set Of ist falsch, da CharacterPosition im Original die untersten 4 Bits sind (Bit 0..3) und in der Übersetzung wurde das Ganze auf ein Bit reduziert. Gleiches gilt für die 3 Bits für block....

himitsu 1. Mär 2010 06:07

Re: Brauche mal Hilfe von einen C++ Spezi
 
Ach menno, hatte mir diese Zahlen als Bit-Positionen gemerkt und nicht als Bit-Anzahl. :oops:

Wenn alles nur ein Bit groß wäre, dann ginge das mit dem SET.

Über ein SET ginge das dann nur noch so, aber dieses wäre umständlich zu nutzen.
Delphi-Quellcode:
X: Set of (characterPositionBit0, characterPositionBit1, characterPositionBit2,
           characterPositionBit3, blockBit0, blockBit1, blockBit2, bDBC);
OK, da der TE zum Glück mindestens ein D20006/TDE besitzt, kommt hier die ultimative Lösung: :angel:
Delphi-Quellcode:
type
  cdTextPackage = record
              packType:         Byte;
              trackNumber:      Byte;
              sequenceNumber:   Byte;
  private
              _block:           Byte;
    function GetCharPos:       Byte;
    procedure SetCharPos    (B: Byte);
    function GetBlock:         Byte;
    procedure SetBlock      (B: Byte);
    function GetDBC:           Byte;
    procedure SetDBC        (B: Byte);
  public
    property characterPosition: Byte read GetCharPos write SetCharPos;
    property block:            Byte read GetBlock  write SetBlock;
    property bDBC:             Byte read GetDBC    write SetDBC;
  public
              data:             Array[0..11] of Byte;
              crc0:             Byte;
              crc1:             Byte;
  end;


function cdTextPackage.GetCharPos: Byte;
begin
  Result := _block and $0F;
end;

procedure cdTextPackage.SetCharPos(B: Byte);
begin
  _block := _block and $F0 or B and $0F;
end;

function cdTextPackage.GetBlock: Byte;
begin
  Result := (_block shr 4) and $07;
end;

procedure cdTextPackage.SetBlock(B: Byte);
begin
  _block := _block and $8F or (B shl 4) and $70;
end;

function cdTextPackage.GetDBC: Byte;
begin
  Result := (_block shr 7) and $01;
end;

procedure cdTextPackage.SetDBC(B: Byte);
begin
  _block := _block and $7F or (B shl 7) and $80;
end;

uligerhardt 1. Mär 2010 09:25

Re: Brauche mal Hilfe von einen C++ Spezi
 
Kuckstu hier.


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz