Trying to parse field definitions
This commit is contained in:
+21
-1
@@ -30,10 +30,17 @@ mutable struct RecordHeader
|
|||||||
local_mesg_type::Int64
|
local_mesg_type::Int64
|
||||||
end
|
end
|
||||||
|
|
||||||
|
struct FieldDefinition
|
||||||
|
number::UInt8
|
||||||
|
sz_bytes::UInt8
|
||||||
|
base_type::AbstractString # Defined in mesg_num.jl
|
||||||
|
end
|
||||||
|
|
||||||
mutable struct DefinitionBody
|
mutable struct DefinitionBody
|
||||||
architecture::AbstractString
|
architecture::AbstractString
|
||||||
global_mesg_type::AbstractString # Read from mesg_num.jl using the bytes in this field.
|
global_mesg_type::AbstractString # Read from mesg_num.jl using the bytes in this field.
|
||||||
num_fields::UInt8
|
num_fields::UInt8
|
||||||
|
field_definitions::Vector{FieldDefinition}
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct DataBody
|
mutable struct DataBody
|
||||||
@@ -123,6 +130,14 @@ function decode_header(v::Vector{UInt8})::RecordHeader
|
|||||||
record
|
record
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function parse_field(bytes::Vector{UInt8})::FieldDefinition
|
||||||
|
FieldDefinition(
|
||||||
|
bytes[1],
|
||||||
|
bytes[2],
|
||||||
|
get_field_definition_string(bytes[3])
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{DefinitionBody, DataBody}
|
read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{DefinitionBody, DataBody}
|
||||||
|
|
||||||
@@ -135,6 +150,10 @@ function read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{Defini
|
|||||||
def_header_bytes = read_bytes!(f, 5)
|
def_header_bytes = read_bytes!(f, 5)
|
||||||
def_header_fields = read_bytes!(f, def_header_bytes[end] * 3)
|
def_header_fields = read_bytes!(f, def_header_bytes[end] * 3)
|
||||||
|
|
||||||
|
# Should always be a multiple of 3
|
||||||
|
# TODO: There is a missing byte here that complicates parsing
|
||||||
|
field_definitions = [parse_field(def_header_bytes[i:i+2]) for i ∈ 1:3:length(def_header_fields)]
|
||||||
|
|
||||||
# See if there is developer data
|
# See if there is developer data
|
||||||
def_header_developer_flag = read_bytes!(f, 1)
|
def_header_developer_flag = read_bytes!(f, 1)
|
||||||
if def_header_developer_flag[1] > 0x00
|
if def_header_developer_flag[1] > 0x00
|
||||||
@@ -148,7 +167,8 @@ function read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{Defini
|
|||||||
DefinitionBody(
|
DefinitionBody(
|
||||||
def_header_bytes[2] == 0 ? "littleendian" : "bigendian",
|
def_header_bytes[2] == 0 ? "littleendian" : "bigendian",
|
||||||
global_mesg_type,
|
global_mesg_type,
|
||||||
def_header_bytes[end]
|
def_header_bytes[end],
|
||||||
|
field_definitions
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user