Read base types of field definitions
parent
27388ba049
commit
7726241012
|
@ -0,0 +1,29 @@
|
|||
module base_types
|
||||
|
||||
export get_base_type
|
||||
|
||||
BASE_TYPE_DICT = Dict(
|
||||
0x00 => Enum,
|
||||
0x01 => Int8,
|
||||
0x02 => UInt8,
|
||||
0x83 => Int16,
|
||||
0x84 => UInt16,
|
||||
0x85 => Int32,
|
||||
0x86 => UInt32,
|
||||
0x07 => AbstractString,
|
||||
0x88 => Float32,
|
||||
0x89 => Float64,
|
||||
0x0a => UInt8, #z?
|
||||
0x8b => UInt16, #z?
|
||||
0x8c => UInt32, #z?
|
||||
0x0d => UInt8, # Byte
|
||||
0x8e => Int64,
|
||||
0x8f => UInt64,
|
||||
0x90 => UInt64 #z?
|
||||
)
|
||||
|
||||
function get_base_type(num::UInt8)::Type
|
||||
BASE_TYPE_DICT[num]
|
||||
end
|
||||
|
||||
end
|
|
@ -6,7 +6,7 @@ export FITFile, read_file, DataRecord
|
|||
|
||||
include("bytes.jl"); using .bytes
|
||||
include("mesg_num.jl"); using .mesg_num
|
||||
|
||||
include("base_types.jl"); using .base_types
|
||||
|
||||
HEADER_SZ = 14
|
||||
|
||||
|
@ -33,7 +33,7 @@ end
|
|||
struct FieldDefinition
|
||||
number::UInt8
|
||||
sz_bytes::UInt8
|
||||
base_type::UInt8 # TODO: This needs to be translated into an actual base type.
|
||||
base_type::Type # TODO: This needs to be translated into an actual base type.
|
||||
end
|
||||
|
||||
mutable struct DefinitionBody
|
||||
|
@ -139,7 +139,7 @@ function parse_field(bytes::Vector{UInt8})::FieldDefinition
|
|||
FieldDefinition(
|
||||
bytes[1],
|
||||
bytes[2],
|
||||
bytes[3]
|
||||
get_base_type(bytes[3])
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -235,7 +235,7 @@ function show(io::IO, defbody::DefinitionBody)
|
|||
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))")
|
||||
println(io, " field_defs=$(defbody.field_definitions)")
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue