Move code around, read header into int/string

This commit is contained in:
2023-04-06 22:44:51 -04:00
parent b6b724f949
commit 37979af849
3 changed files with 53 additions and 32 deletions
+26
View File
@@ -0,0 +1,26 @@
"""
read_data_size(size::Vector{UInt8})::Real
FIT headers have a data size field, with 4 bytes.
"""
function byte_vec_to_int(byte_vec::Vector{UInt8})::Integer
result::Integer = 0
byte_vec = Int64.(byte_vec)
for i 0:length(byte_vec) - 1
result += byte_vec[1 + i] << (8 * i)
end
return result
end
"""
byte_vec_to_string(byte_vec::Vector{UInt8})::AbstractString
Given the byte vec, create a String
"""
function byte_vec_to_string(byte_vec::Vector{UInt8})::AbstractString
String(Char.(byte_vec))
end
# byte_vec_to_string(UInt8.(collect("ABC")))