forked from tomerfiliba/construct3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from construct3 import * | ||
''' | ||
transport_packet(){ | ||
sync_byte 8 bslbf | ||
transport_error_indicator 1 bslbf | ||
payload_unit_start_indicator 1 bslbf | ||
transport_priority 1 bslbf | ||
PID 13 uimsbf | ||
transport_scrambling_control 2 bslbf | ||
adaptation_field_control 2 bslbf | ||
continuity_counter 4 uimsbf | ||
if(adaptation_field_control == '10' || adaptation_field_control == '11'){ | ||
adaptation_field() | ||
} | ||
if(adaptation_field_control == '01' || adaptation_field_control == '11') { | ||
for (i = 0; i < N; i++){ | ||
data_byte 8 bslbf | ||
} | ||
} | ||
} | ||
''' | ||
transport_packet = Struct( | ||
"sync_byte" / uint8, | ||
Embedded(BitStruct( | ||
"transport_error_indicator" / flag, | ||
"payload_unit_start_indicator" / flag, | ||
"transport_priority" / flag, | ||
"PID" / Bits(13), | ||
"transport_scrambling_control" / Bits(2), | ||
"adaptation_field_exist" / flag, | ||
"payload_exist" / flag, | ||
"continuity_counter" / Bits(4), | ||
) | ||
), | ||
#''' | ||
#If(lambda ctx: ctx.adaptation_field_exist, | ||
# | ||
#), | ||
#If(lambda ctx: ctx.payload_exist, | ||
# | ||
#), | ||
#''' | ||
) | ||
|
||
if __name__ == "__main__": | ||
import binascii | ||
print transport_packet.unpack(binascii.unhexlify("47666666")) | ||
|