This function reads and processes regular and repeated blocks of data based on provided specifications. Regular blocks are read directly, while repeated blocks are processed recursively based on a set of loops provided in the specifications.
Usage
readV6BlockData(
specs,
connection,
endian = "big",
prev_data = NULL,
remaining_loops = NULL
)
Arguments
- specs
A list. Specifications detailing the structure and content of the data blocks. Contains variable names, types, quality check functions, and other related attributes. For repeated blocks, a 'repeat' key is added which details the loop structure and nested specifications.
- connection
A connection object. Represents the connection to the data source. It's passed to the lower-level reading function.
- endian
A character string. Specifies the byte order to be used. Default is "big". Passed to the lower-level reading function.
- prev_data
A list. Previous data or metadata that might be required to inform the reading process, such as loop lengths for repeated blocks. Default is NULL.
- remaining_loops
A character vector. Details the remaining loops to be processed for repeated blocks. Internally used for recursive processing. Default is NULL. If provided, it should always be in sync with the repeat specifications.
Value
A list. Contains the read and processed data based on the provided specifications. Regular variables are returned at the top level. Repeated blocks are nested lists with 'loop' and 'data' keys detailing the loop variable and corresponding data.
Examples
# Example: read a single UInt8 value using internal helper
specs <- list(
field1 = list(
type = "UInt8",
qc_fun = "qc_check_unsigned",
qc_params = list()
)
)
con <- rawConnection(as.raw(c(10)), "rb")
result <- readV6BlockData(specs, con, endian = "big")
print(result)
#> $field1
#> [1] 10
#>
close(con)