Properly reading the field definitions now.
parent
475341ffb4
commit
27388ba049
16
src/file.jl
16
src/file.jl
|
@ -33,7 +33,7 @@ end
|
|||
struct FieldDefinition
|
||||
number::UInt8
|
||||
sz_bytes::UInt8
|
||||
base_type::AbstractString # Defined in mesg_num.jl
|
||||
base_type::UInt8 # TODO: This needs to be translated into an actual base type.
|
||||
end
|
||||
|
||||
mutable struct DefinitionBody
|
||||
|
@ -130,11 +130,16 @@ function decode_header(v::Vector{UInt8})::RecordHeader
|
|||
record
|
||||
end
|
||||
|
||||
"""
|
||||
parse_field(bytes::Vector{UInt8})::FieldDefinition
|
||||
|
||||
Parse a field definition in the definition message into a struct
|
||||
"""
|
||||
function parse_field(bytes::Vector{UInt8})::FieldDefinition
|
||||
FieldDefinition(
|
||||
bytes[1],
|
||||
bytes[2],
|
||||
get_field_definition_string(bytes[3])
|
||||
bytes[3]
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -152,7 +157,7 @@ function read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{Defini
|
|||
|
||||
# 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)]
|
||||
field_definitions = [parse_field(def_header_fields[i:i+2]) for i ∈ 1:3:length(def_header_fields)]
|
||||
|
||||
# See if there is developer data
|
||||
def_header_developer_flag = read_bytes!(f, 1)
|
||||
|
@ -227,7 +232,10 @@ function show(io::IO, ffr::FITFileReader)
|
|||
end
|
||||
|
||||
function show(io::IO, defbody::DefinitionBody)
|
||||
println(io, "DefinitionBody(arch=$(defbody.architecture), global_type=$(defbody.global_mesg_type), num_fields=$(defbody.num_fields))")
|
||||
println(io, "DefinitionBody(arch=$(defbody.architecture),")
|
||||
println(io, " global_type=$(defbody.global_mesg_type)")
|
||||
println(io, " num_fields=$(defbody.num_fields)")
|
||||
println(io, " field_defs=$(defbody.field_definitions))")
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue