How to use the construct.UBInt16 function in construct

To help you get started, we’ve selected a few construct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ayrx / tlsenum / tlsenum / hello_constructs.py View on Github external
"ec_curves",
    UBInt16("ec_curves_length"),
    Array(lambda ctx: ctx.ec_curves_length // 2, UBInt16("named_curves"))
)

ServerName = Struct(
    "server_name",
    UBInt16("server_name_list_length"),
    UBInt8("name_type"),
    UBInt16("server_name_length"),
    Bytes("server_name", lambda ctx: ctx.server_name_length)
)

Extension = Struct(
    "extension",
    UBInt16("extension_type"),
    UBInt16("extension_length"),
    Switch("extension_struct", lambda ctx: ctx.extension_type, {
        0: ServerName,
        10: ECCurves,
        11: ECPointFormat
    })
github bravoserver / bravo / beta / packets.py View on Github external
UBInt8("enabled"),
    ),
    51: Struct("chunk",
        SBInt32("x"),
        UBInt16("y"),
        SBInt32("z"),
        UBInt8("x_size"),
        UBInt8("y_size"),
        UBInt8("z_size"),
        PascalString("data", length_field=UBInt32("length"), encoding="zlib"),
    ),
    52: Struct("batch",
        SBInt32("x"),
        SBInt32("z"),
        UBInt16("length"),
        MetaArray(lambda context: context["length"], UBInt16("coords")),
        MetaArray(lambda context: context["length"], UBInt8("types")),
        MetaArray(lambda context: context["length"], UBInt8("metadata")),
    ),
    53: Struct("block",
        SBInt32("x"),
        UBInt8("y"),
        SBInt32("z"),
        UBInt8("type"),
        UBInt8("meta"),
    ),
    59: Struct("tile_entity",
        SBInt32("x"),
        SBInt16("y"),
        SBInt32("z"),
        PascalString("nbt", length_field=UBInt16("length")),
    ),
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
construct.SBInt16("recUpholeTime"),
                             # Source static correction in ms
                             construct.SBInt16("sourceStaticCor"),
                             # Group static correction in ms
                             construct.SBInt16("recStaticCor"),
                             # Total static applied in ms
                             construct.SBInt16("totalStatic"),
                             construct.SBInt16("lagTimeA"),  # Lag time A, ms
                             construct.SBInt16("lagTimeB"),  # Lag time B, ms
                             # Delay recording time, ms
                             construct.SBInt16("delay"),
                             # Mute start time, ms
                             construct.SBInt16("muteStart"),
                             construct.SBInt16("muteEnd"),  # Mute end time, ms
                             # *** Number of samples ***
                             construct.UBInt16("sampleLength"),
                             # *** Sample interval, us ***
                             construct.SBInt16("deltaSample"),
                             construct.SBInt16("gainType"),  # Gain type
                             construct.SBInt16("gainConst"),  # Gain constant
                             construct.SBInt16("initialGain"),  # Early gain
                             construct.SBInt16("correlated"),  # Correlated?
                             # Sweep frequency at start
                             construct.SBInt16("sweepStart"),
                             # Sweep frequency at end
                             construct.SBInt16("sweepEnd"),
                             # Sweep length in ms
                             construct.SBInt16("sweepLength"),
                             construct.SBInt16("sweepType"),  # Sweep type
                             # Sweep taper at start, ms
                             construct.SBInt16("sweepTaperAtStart"),
                             # Sweep taper at end, ms
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
def swap_block_16():
    B = construct.Struct("BIN",
                         construct.UBInt16('A'),
                         construct.UBInt16('B'),
                         construct.UBInt16('C'),
                         construct.UBInt16('D'),
                         construct.UBInt16('E'),
                         construct.UBInt16('F'),
                         construct.UBInt16('G'),
                         construct.UBInt16('H'),
                         construct.UBInt16('I'),
                         construct.UBInt16('J'),
                         construct.UBInt16('K'),
                         construct.UBInt16('L'),
                         construct.UBInt16('M'),
                         construct.UBInt16('N'),
                         construct.UBInt16('O'),
                         construct.UBInt16('P')
                         )
    L = construct.Struct("BIN",
                         construct.ULInt16('A'),
                         construct.ULInt16('B'),
                         construct.ULInt16('C'),
                         construct.ULInt16('D'),
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
construct.UBInt8("DevStatusBits"),
                             #    Bit 0 -- A/D Modulator Over-range
                             #    Bit 1 -- A/D Decimator Numerical Overflow
                             #    Bit 2 -- Analog Preamp Overscale or
                             # VSMT Data Invalid
                             #    Bit 3 -- SVSM VLFF error
                             #    Bit 4 -- Invalid Receiver Line/Station
                             #    Bit 5 -- Trace was Zero filled (T2 only)
                             #    Bit 6 -- Battery improperly removed
                             #    Bit 7 -- SVSM Dynamic Offset Filter mode,
                             # 0 = static
                             # BIT test type and codes (0 - 28) See FireFly SEG
                             # Y Ver 3.0 Tech Bulletin
                             construct.UBInt8("BITTest"),
                             # Sweep Phase Rotation; 0 if undefined
                             construct.UBInt16("SweepPhaseRot"),
                             construct.UBInt8("unass03"),  # Unassigned
                             construct.UBInt8("BoxFun"),  # Box function
                             # Source effort used to generate the trace
                             # (mantissa)
                             construct.UBInt32("SourceEffortM"),
                             # Source effort, (exponent)
                             construct.UBInt16("SourceEffortE"),
                             # Source measurement units
                             construct.UBInt16("SourceUnits"),
                             #    -1 -- Other
                             #    0 -- Unknown
                             #    1 -- Joule
                             #    2 -- Kilowatt
                             #    3 -- Pascal
                             #    4 -- Bar
                             #    5 -- Bar-meter
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
def reel_header():
    REEL = construct.Struct("REEL",
                            # Job identification number
                            construct.UBInt32("jobid"),
                            construct.UBInt32("lino"),  # Line number
                            construct.UBInt32("reno"),  # Reel number
                            construct.UBInt16("ntrpr"),  # Traces per ensemble
                            # Aux traces per ensemble
                            construct.UBInt16("nart"),
                            # ***   Sample interval us   ***
                            construct.UBInt16("hdt"),
                            construct.UBInt16("dto"),  # Field sample interval
                            # ***   Number of samples per trace   ***
                            construct.UBInt16("hns"),
                            # Field samples per trace
                            construct.UBInt16("nso"),
                            # ***  Data format, 5 = 4-byte IEEE   ***
                            construct.UBInt16("format"),
                            construct.UBInt16("fold"),  # Ensemble fold
                            # Trace sorting code, 5 == shot gathers
                            construct.UBInt16("tsort"),
                            construct.UBInt16("vscode"),  # Vertical sum code
                            # Starting sweep frequency
                            construct.UBInt16("hsfs"),
                            # Ending sweep frequency
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
def reel_header():
    REEL = construct.Struct("REEL",
                            # Job identification number
                            construct.UBInt32("jobid"),
                            construct.UBInt32("lino"),  # Line number
                            construct.UBInt32("reno"),  # Reel number
                            construct.UBInt16("ntrpr"),  # Traces per ensemble
                            # Aux traces per ensemble
                            construct.UBInt16("nart"),
                            # ***   Sample interval us   ***
                            construct.UBInt16("hdt"),
                            construct.UBInt16("dto"),  # Field sample interval
                            # ***   Number of samples per trace   ***
                            construct.UBInt16("hns"),
                            # Field samples per trace
                            construct.UBInt16("nso"),
                            # ***  Data format, 5 = 4-byte IEEE   ***
                            construct.UBInt16("format"),
                            construct.UBInt16("fold"),  # Ensemble fold
                            # Trace sorting code, 5 == shot gathers
                            construct.UBInt16("tsort"),
                            construct.UBInt16("vscode"),  # Vertical sum code
                            # Starting sweep frequency
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
#    Bit 5 -- Trace was Zero filled (T2 only)
                             #    Bit 6 -- Battery improperly removed
                             #    Bit 7 -- SVSM Dynamic Offset Filter mode,
                             # 0 = static
                             # BIT test type and codes (0 - 28) See FireFly SEG
                             # Y Ver 3.0 Tech Bulletin
                             construct.UBInt8("BITTest"),
                             # Sweep Phase Rotation; 0 if undefined
                             construct.UBInt16("SweepPhaseRot"),
                             construct.UBInt8("unass03"),  # Unassigned
                             construct.UBInt8("BoxFun"),  # Box function
                             # Source effort used to generate the trace
                             # (mantissa)
                             construct.UBInt32("SourceEffortM"),
                             # Source effort, (exponent)
                             construct.UBInt16("SourceEffortE"),
                             # Source measurement units
                             construct.UBInt16("SourceUnits"),
                             #    -1 -- Other
                             #    0 -- Unknown
                             #    1 -- Joule
                             #    2 -- Kilowatt
                             #    3 -- Pascal
                             #    4 -- Bar
                             #    5 -- Bar-meter
                             #    6 -- Kilograms
                             #    7 -- Pounds
                             construct.UBInt8("EventType"),  # Event type:
                             #    0x00 -- Zeroed or truncated trace
                             #    0x40 -- BIT data - Raw Trace
                             #    0x80 -- Seis data - Normal, Raw
                             #    0x88 -- Seis data - Normal, Stack
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
B = construct.Struct("BIN",
                         construct.UBInt16('A'),
                         construct.UBInt16('B'),
                         construct.UBInt16('C'),
                         construct.UBInt16('D'),
                         construct.UBInt16('E'),
                         construct.UBInt16('F'),
                         construct.UBInt16('G'),
                         construct.UBInt16('H'),
                         construct.UBInt16('I'),
                         construct.UBInt16('J'),
                         construct.UBInt16('K'),
                         construct.UBInt16('L'),
                         construct.UBInt16('M'),
                         construct.UBInt16('N'),
                         construct.UBInt16('O'),
                         construct.UBInt16('P')
                         )
    L = construct.Struct("BIN",
                         construct.ULInt16('A'),
                         construct.ULInt16('B'),
                         construct.ULInt16('C'),
                         construct.ULInt16('D'),
                         construct.ULInt16('E'),
                         construct.ULInt16('F'),
                         construct.ULInt16('G'),
                         construct.ULInt16('H'),
                         construct.ULInt16('I'),
                         construct.ULInt16('J'),
                         construct.ULInt16('K'),
                         construct.ULInt16('L'),
                         construct.ULInt16('M'),