Main Content

read

Read next VITA 49 packet

Since R2022b

    Description

    example

    [signalDataPacket,contextPacket,contextPacketChangeIndex] = read(vita49ReaderObj) reads the next packet from the VMEbus International Trade Association (VITA) 49 file specified by the input VITA 49 file reader object, vita49ReaderObj, and returns the signal data packet, signalDataPacket, and context packet, contextPacket. The function also returns the starting indices of the signal data packets after any new context packet arrival, in contextPacketChangeIndex. Note that the read function will terminate if it finds any ill-formatted packet while reading the file.

    example

    [signalDataPacket,contextPacket,contextPacketChangeIndex,commandPacket,processedLength] = read(vita49ReaderObj,data) reads the next packet form the VITA 49 data specified by data variable in the VITA 49 file reader object, vita49ReaderObj. The function also returns the number of decoded bytes processedLength from the given VITA 49 data.

    example

    [___] = read(vita49ReaderObj,Name=Value) specifies one or more optional name-value arguments, in addition to the output arguments from the previous syntax. For example, StreamID=2 sets the stream identifier to 2.

    Examples

    collapse all

    Create a VITA 49 file reader object, specifying the name of a VITA 49 file and an output format for the packet timestamp.

    vita49ReaderObj = vita49Reader("VITA49SampleData.bin");
    vita49ReaderObj.OutputTimestampFormat = "seconds";

    Specify the number of packets to be read from the file.

    numpkt = 11;

    Read the specified number of packets from the VITA 49 file to the MATLAB® workspace.

    [signalDataPacket,contextPacket,contextPacketChangeIndex] = read(vita49ReaderObj,NumPackets=numpkt)
    signalDataPacket = struct with fields:
                      PacketType: 1
                        StreamID: 0
                         ClassID: "7C386C0000"
                     PadBitCount: 0
            IntegerTimestampType: "GPS"
           IntegerTimestampValue: 1625215654
         FractionalTimestampType: "real time"
        FractionalTimestampValue: 900000344000
                        RawBytes: [1472x1 uint8]
                       IQSamples: [722x1 double]
                         Trailer: [1x1 struct]
    
    
    contextPacket=1×10 struct array with fields:
        PacketType
        StreamID
        ClassID
        IntegerTimestampType
        IntegerTimestampValue
        FractionalTimestampType
        FractionalTimestampValue
        RawBytes
        ContextFieldChangeIndicator
        ReferencePointIdentifier
        Bandwidth
        IFReferenceFrequency
        RFFrequency
        RFFrequencyOffset
        IFBandOffset
        ReferenceLevel
        Gain
        OverRangeCount
        SampleRate
        TimestampAdjustment
        TimestampCalibrationTime
        StateAndEventIndicator
        SignalDataPayloadFormat
          ⋮
    
    
    contextPacketChangeIndex = 1×10
    
         0     0     0     0     0     0     0     0     0     1
    
    

    Clear the vita49Reader System object.

    clear vita49ReaderObj

    Create a VITA 49 file reader object, specifying the name of a VITA 49 file.

    vita49ReaderObj = vita49Reader("VITA49SampleData.bin");

    Set the stream identifier as 1, class identifier as "736C860000", and packet type as signal data packet.

    pktType = "signal data";
    streamID = 0;
    classID = "7C386C0000";

    In streaming mode, read the VITA 49 packets that match the specified filters to the MATLAB workspace.

    for idx = 1:3
        signalDataPacket = read(vita49ReaderObj, ...
          PacketType=pktType,StreamID=streamID,ClassID=classID)
    end
    signalDataPacket = struct with fields:
                      PacketType: 1
                        StreamID: 0
                         ClassID: "7C386C0000"
                     PadBitCount: 0
            IntegerTimestampType: "GPS"
           IntegerTimestampValue: 1625215654
         FractionalTimestampType: "real time"
        FractionalTimestampValue: 900000344000
                        RawBytes: [1472x1 uint8]
                       IQSamples: [722x1 double]
                         Trailer: [1x1 struct]
    
    
    signalDataPacket = struct with fields:
                      PacketType: 1
                        StreamID: 0
                         ClassID: "7C386C0000"
                     PadBitCount: 0
            IntegerTimestampType: "GPS"
           IntegerTimestampValue: 1625215654
         FractionalTimestampType: "real time"
        FractionalTimestampValue: 900042328000
                        RawBytes: [1472x1 uint8]
                       IQSamples: [722x1 double]
                         Trailer: [1x1 struct]
    
    
    signalDataPacket = struct with fields:
                      PacketType: 1
                        StreamID: 0
                         ClassID: "7C386C0000"
                     PadBitCount: 0
            IntegerTimestampType: "GPS"
           IntegerTimestampValue: 1625215654
         FractionalTimestampType: "real time"
        FractionalTimestampValue: 900084248000
                        RawBytes: [1472x1 uint8]
                       IQSamples: [722x1 double]
                         Trailer: [1x1 struct]
    
    

    Clear the vita49Reader System object.

    clear vita49ReaderObj

    Create a VITA 49 file reader object without any input arguments.

    vita49ReaderObj = vita49Reader;

    Load vita49Data.mat into the workspace.

    load('vita49Data.mat')

    The vita49Data.mat consists of a variable data with 37 VITA 49 packets. Read the VITA 49 packets from the variable data.

    [sigDataPackets,contextPackets,contextChangeIdx,commandPackets, ...
          processedlen] = read(vita49ReaderObj, data, "NumPackets",37);

    Clear the vita49Reader System object.

    clear vita49ReaderObj

    Input Arguments

    collapse all

    VITA 49 file reader, specified as a vita49Reader object.

    VITA 49 formatted data, specified as a unit8 array in the workspace.

    Data Types: uint8

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: StreamID=2 sets the stream identifier to 2.

    Type of packet to be read, specified as "signal data", "context", or "command". If you do not specify this argument, the function reads the next packet from the file.

    Data Types: char | string

    Number of packets to be read, specified as a positive integer. To read all packets up to the end of the file, set NumPackets to intmax ("uint32") or intmax ("uint64").

    Data Types: double | uint32 | uint64

    Stream identifier, specified as a nonnegative integer.

    If you specify StreamID, the function identifies the packets belonging to only the specified ID from the packet stream.

    Data Types: uint32

    Class identifier, specified as a character vector or string scalar.

    A class identifier is a 5-byte-long, hex-formatted string that includes three bytes of Organizational Unique Identifier (OUI) information and two bytes of information class code.

    Data Types: char | string

    Output Arguments

    collapse all

    Decoded signal data packet, returned as a structure. For more information about this output, see Signal Data Packet.

    Data Types: struct

    Decoded context packet, returned as a structure. For more information about this output, see Context Packet.

    Data Types: struct

    Starting indices of the signal data packets after any new context packet arrival, returned as an array of nonnegative integers.

    When two context packets arrive one after another, the corresponding value returned is two zeros.

    Data Types: double

    Undecoded command packet, returned as a structure. For more information about this output, see Command Packet.

    Data Types: struct

    Number of bytes processed in a read call, returned as a nonnegative integer.

    Data Types: double

    Extended Capabilities

    Version History

    Introduced in R2022b

    See Also

    Objects

    Functions