How to use the construct.UBInt8 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 PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
def extended_header_2():
    BIN = construct.Struct("BIN",
                           construct.BFloat32("drift_window"),
                           construct.UBInt64("clock_drift_ns"),
                           # Clock stop method
                           construct.UBInt8("clock_stop_method"),
                           # 0 - normal
                           # 1 - storage full
                           # 2 - power loss
                           # 3 - reboot by command
                           # Frequency drift flag
                           construct.UBInt8("Frequency_drift"),
                           # 0 - not in spec
                           # 1 - in spec
                           # Oscillator type
                           construct.UBInt8("oscillator_type"),
                           # 0 - control board
                           # 1 - atomic
                           # 2 - ovenized
                           # 3 - double ovenized
                           # 4 - disciplined
                           # 0 - normal (shots)
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
# (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
                             #    0x90 -- Seis data - Normal, Correlated
                             #    0xA0 -- Seis data - Test, Raw
                             #    0xA8 -- Seis data - Test, Stack
                             #    0xB0 -- Seis data - Test, Correlated
                             # Sensor type ID
                             construct.UBInt8("SensorTypeID"),
                             #    0x00 -- No sensor defined
                             #    0x01 -- Geophone - 1 component vertical
                             #    0x02 -- Marshphone
                             #    0x03 -- Hydrophone
                             #    0x04 -- Aux
                             #    0x05 -- Geophone-3c Horizontal,
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
# 2 - ovenized
                           # 3 - double ovenized
                           # 4 - disciplined
                           # 0 - normal (shots)
                           construct.UBInt8("collection_method"),
                           # 1 - continuous (fixed time slice)
                           # 2 - shot sliced with guard band
                           # Number of traces
                           construct.UBInt32("number_records"),
                           construct.UBInt32("number_files"),
                           construct.UBInt32("file_number"),
                           # Decimation flag
                           construct.UBInt8("decimation_flag"),
                           # 0 - not decimated
                           # 1 - decimated
                           construct.UBInt8("base_scan_interval"),
                           construct.UBInt16("decimation_filter_coefficients")
                           )
    return BIN
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
construct.UBInt8("VectSens"),
                             #    0 = 40nG
                             #    3 = 160nG
                             # Absolute horizontal orientation azimuth of
                             # Vectorseis in
                             construct.UBInt16("HorAz"),
                             # 0.0001 radians, measured from due-North
                             # Absolute vertical orientation angle, in 0.0001
                             # radians.
                             construct.UBInt16("VertAngle"),
                             # A vertically planted sensor will
                             # have a value of
                             # 1416 (Pi * 10,000),
                             # while a horizontally planted sensor will have a
                             # value of 15708 (Pi/2 * 10,000)
                             construct.UBInt8("SourceType"),  # Source type:
                             #    0 -- Built-in test
                             #    1 -- Dynamite
                             #    2 -- Vibrator
                             #    3 -- AirGun
                             #    4 -- WaterGun
                             #    5 -- WeightDrop
                             #    6 -- Other
                             #    7 -- MixedSources
                             #    8 -- NoSource or Unknown
                             #    9 -- TestOsc (For GDC this is an
                             # external test
                             # oscillator)
                             #    10 -- Impulsive
                             construct.UBInt8("SensorType"),  # Sensor type:
                             #    0 -- Unknown
                             #    1 -- Hydrophone
github PIC-IRIS / PH5 / ph5 / core / rt_130_h.py View on Github external
def filter_info():
    FI = construct.Struct("FI",
                          construct.UBInt8("FilterBlockCount"),
                          construct.String("FilterID", 1),
                          construct.UBInt8("FilterDecimation"),
                          construct.UBInt8("FilterScaler"),
                          construct.UBInt8("FilterCoefficientCount"),
                          construct.UBInt8("PacketCoefficientCount"),
                          construct.UBInt8("CoefficientPacketCount"),
                          construct.UBInt8("CoefficientFormat"))
    return FI
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
#    0x3F -- Unused Channel
                             construct.UBInt8("AuxChanID"),  # Aux Channel ID
                             # Shot Point Line in hundredths
                             construct.UBInt32("SPL"),
                             # Shot Point Station in hundredths
                             construct.UBInt32("SPS"),
                             construct.UBInt16("unass01"),  # Unassigned
                             construct.UBInt16("unass02"),  # Unassigned
                             # Sensor Interface Unit Type
                             construct.UBInt8("SenInt"),
                             #    18 -- VSM
                             #    21 -- Vectorseis
                             #    42 -- Geophone Digitizer Unit
                             #    49 -- iNova Standard Analog Channel GDC
                             # Vectorseis sensitivity
                             construct.UBInt8("VectSens"),
                             #    0 = 40nG
                             #    3 = 160nG
                             # Absolute horizontal orientation azimuth of
                             # Vectorseis in
                             construct.UBInt16("HorAz"),
                             # 0.0001 radians, measured from due-North
                             # Absolute vertical orientation angle, in 0.0001
                             # radians.
                             construct.UBInt16("VertAngle"),
                             # A vertically planted sensor will
                             # have a value of
                             # 1416 (Pi * 10,000),
                             # while a horizontally planted sensor will have a
                             # value of 15708 (Pi/2 * 10,000)
                             construct.UBInt8("SourceType"),  # Source type:
                             #    0 -- Built-in test
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
def extended_header_3():
    swap = True
    if sys.byteorder == 'big':
        swap = False

    BIN = construct.Struct("BIN",
                           construct.UBInt32("line_number"),
                           construct.UBInt32("receiver_point"),
                           construct.UBInt8("point_index"),
                           construct.UBInt32("first_shot_line"),
                           construct.UBInt32("first_shot_point"),
                           construct.UBInt8("first_shot_point_index"),
                           construct.UBInt32("last_shot_line"),
                           construct.UBInt32("last_shot_point"),
                           construct.UBInt8("last_shot_point_index"),
                           construct.BitField("reserved01", 5, swapped=swap)
                           )
    return BIN
github lukleh / TwistedBot / twistedbot / packets.py View on Github external
UBInt32("eid"),
               UBInt32("vehicle_id"),
               ),
    40: Struct("entity metadata",
               UBInt32("eid"),
               entity_metadata,
               ),
    41: Struct("entity effect",
               UBInt32("eid"),
               UBInt8("effect"),
               UBInt8("amount"),
               UBInt16("duration"),
               ),
    42: Struct("remove entity effect",
               UBInt32("eid"),
               UBInt8("effect"),
               ),
    43: Struct("set experience",
               BFloat32("current"),
               UBInt16("level"),
               UBInt16("total"),
               ),
    51: Struct("chunk data",
               SBInt32("x"),
               SBInt32("z"),
               Bool("continuous"),
               UBInt16("primary_bitmap"),
               UBInt16("add_bitmap"),
               SBInt32("size"),
               #ByteString("data", size_name="size", encoding="zlib"),
               MetaField("data", lambda ctx: ctx["size"]),
               ),
github python-tls / tls / tls / _common / _constructs.py View on Github external
def PrefixedBytes(name, length_field=construct.UBInt8("length")):  # noqa
    """
    Length-prefixed binary data.  This is like a
    :py:func:`construct.macros.PascalString` that raises a
    :py:class:`constrcut.AdaptationError` when encoding something
    other than :py:class:`bytes`.

    :param name: The attribute name under which this value will be
        accessible.
    :type name: :py:class:`str`

    :param length_field: (optional) The prefixed length field.
        Defaults to :py:func:`construct.macros.UBInt8`.
    :type length_field: a :py:class:`construct.core.FormatField`
    """
    return construct.LengthValueAdapter(
        construct.Sequence(
github lukleh / TwistedBot / twistedbot / packets.py View on Github external
UBInt8("flags"),
                Value("is_god", lambda ctx: ctx["flags"] & 1),
                Value("is_flying", lambda ctx: ctx["flags"] & 2),
                Value("can_fly", lambda ctx: ctx["flags"] & 4),
                Value("is_creative", lambda ctx: ctx["flags"] & 8),
                UBInt8("walking_speed"),
                UBInt8("flying_speed"),
                ),
    203: Struct("tab complete",
                AlphaString("text"),
                ),
    204: Struct("locale view distance",
                AlphaString("locale"),
                UBInt8("view_distance"),  # 0 0:far, 1:normal, 2:short, 3:tiny
                UBInt8("chat_flags"),  # 0 on, no colors
                UBInt8("difficulty"),  # 0 0-peacefull,easy, normal, 3-hard
                Bool("show_cape"),
                ),
    205: Struct("client statuses",
                UBInt8("status"),
                ),
    206: Struct("create scoreboard",
                AlphaString("name"),
                AlphaString("display_text"),
                SBInt8("create_remove"),
                ),
    207: Struct("update scoreboard",
                AlphaString("item_name"),
                SBInt8("update_remove"),
                If(lambda context: context["update_remove"] != 1,
                  Embed(Struct("namevalue",
                    AlphaString("score_name"),