![]() |
Brauche mal Hilfe von einen C++ Spezi
Code:
Kann mir das bitte einer ,von C++, nach
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; Pascal überstzen und wiviel bytes benutzt werden. Danke |
Re: Brauche mal Hilfe von einen C++ Spezi
Delphi-Quellcode:
[...] = ein statisches Array
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; :X = ein Bit-Feld (dafür gibt es in Pascal keine wirkliche Entsprechnung) |
Re: Brauche mal Hilfe von einen C++ Spezi
Zitat:
|
Re: Brauche mal Hilfe von einen C++ Spezi
Ihr seit toll Danke. :angel:
Admin wie schließe ich ein Thema? |
Re: Brauche mal Hilfe von einen C++ Spezi
1. seid (
![]() 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.... |
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:
OK, da der TE zum Glück mindestens ein D20006/TDE besitzt, kommt hier die ultimative Lösung: :angel:
X: Set of (characterPositionBit0, characterPositionBit1, characterPositionBit2,
characterPositionBit3, blockBit0, blockBit1, blockBit2, bDBC);
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; |
Re: Brauche mal Hilfe von einen C++ Spezi
Kuckstu
![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:28 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz