Compare commits
2 Commits
9dd04d2cb1
...
977b9bf507
Author | SHA1 | Date |
---|---|---|
Jacob Windle | 977b9bf507 | |
Jacob Windle | 83c34dbe23 |
13
src/body.jl
13
src/body.jl
|
@ -8,8 +8,8 @@ import Base.show
|
|||
|
||||
export RecordHeader, read_row
|
||||
|
||||
include("mesg_num.jl")
|
||||
using .mesg_num
|
||||
include("bytes.jl"); using.bytes
|
||||
include("mesg_num.jl"); using .mesg_num
|
||||
|
||||
struct DefinitionMessage end
|
||||
struct DataMessage end
|
||||
|
@ -21,6 +21,7 @@ The byte that corresponds to the type of message that this record holds.
|
|||
"""
|
||||
struct RecordHeader
|
||||
definition_message::Bool
|
||||
timestamp_message::Bool
|
||||
end
|
||||
|
||||
|
||||
|
@ -32,13 +33,11 @@ TODO: Endianness matters here. Need to resolve endianness with the architecture
|
|||
"""
|
||||
function read_row(f::IO)
|
||||
header_byte = read(f, 1; all=false)[1]
|
||||
println(bitstring(header_byte))
|
||||
|
||||
# The message byte is 7
|
||||
RecordHeader(Bool(parse(Int64, bitstring(header_byte)[2])))
|
||||
end
|
||||
|
||||
function read_header_byte(f::Core.IO)
|
||||
RecordHeader(
|
||||
bit_at(header_byte, 2),
|
||||
bit_at(header_byte, 1))
|
||||
end
|
||||
|
||||
function show(io::IO, header::RecordHeader)
|
||||
|
|
13
src/bytes.jl
13
src/bytes.jl
|
@ -1,3 +1,6 @@
|
|||
module bytes
|
||||
|
||||
export byte_vec_to_int, byte_vec_to_string, bit_at
|
||||
|
||||
"""
|
||||
read_data_size(size::Vector{UInt8})::Real
|
||||
|
@ -23,4 +26,14 @@ function byte_vec_to_string(byte_vec::Vector{UInt8})::AbstractString
|
|||
String(Char.(byte_vec))
|
||||
end
|
||||
|
||||
"""
|
||||
bit_at(byte::UInt8, idx::Int64; t::Type=Int64)::Int64
|
||||
|
||||
Parse the bit at specific index in byte
|
||||
"""
|
||||
function bit_at(byte::UInt8, idx::Int64; t::Type=Int64)::Int64
|
||||
parse(t, bitstring(byte)[idx])
|
||||
end
|
||||
|
||||
end
|
||||
# byte_vec_to_string(UInt8.(collect("ABC")))
|
|
@ -7,7 +7,8 @@
|
|||
module header
|
||||
|
||||
export FITHeader, read_header
|
||||
include("bytes.jl")
|
||||
|
||||
include("bytes.jl"); using .bytes
|
||||
|
||||
const DATA_SIZE_LENGTH = 4
|
||||
|
||||
|
|
Loading…
Reference in New Issue