VITA Radio Transport in Julia
VRT.jl provides support for reading and writing VITA 49 streams in pure Julia. It is a very young package, and by no means supports all of the features of VITA 49.2.
VRT.jl is not yet registered, so you will need to use the Pkg package to install it.
pkg> add https://github.com/maleadt/VRT.jlAfter importing the package, you can read packages from a stream by using the read
function, and write them back using the write function:
julia> io = ...
julia> read(io, AbstractVRTPacket)
VRTContextPacket(
...
)
julia> write(io, VRTContextPacket(...))To create a new packet, use the appropriate constructor to create an initial object, and
then use @set from Accessors.jl to initialize the immutable fields (using the field
hierarchy as shown in the output, whic follows the packet structure as defined in the spec):
julia> packet = VRTContextPacket()
VRTContextPacket(
# prologue
header: VRTPacketHeader(
packet_type: VRT_PT_CONTEXT
has_class_id: false
indicators: VRTPacketIndicators(
nd0: false
tsm: false
)
tsi: VRT_TSI_NONE
tsf: VRT_TSF_NONE
packet_count: 0
packet_size: 0
)
stream_id: 0
context_fields: VRTFields()
)
julia> packet = Accessors.@set packet.header.indicators.nd0 = true
VRTContextPacket(
header: VRTPacketHeader(
indicators: VRTPacketIndicators(
nd0: true
)
)For more complicated fields that require setting multiple fields or specially-encoded
values, such as the timestamp, functions are provided to help you:
julia> VRT.set_timestamp(packet, Dates.now())
VRTContextPacket(
header: VRTPacketHeader(
tsi: VRT_TSI_UTC
tsf: VRT_TSF_REAL_TIME
)
timestamp: 2025-03-20T13:30:37.704 TAI
integer part: 1742477400
fractional part: 703999996185
)