Skip to contents

This function reads an array of numbers from a binary connection using a custom command-based protocol. A block of data is processed according to its size specified in key$size. Within the block, the first byte read is a command byte that determines how the subsequent bytes are interpreted. The function updates a running "tracking value" based on the commands encountered and returns a vector of decoded numbers. The supported commands are:

Usage

seasonder_read_reduced_encoded_data(connection, key, endian = "big")

Arguments

connection

A binary connection from which the encoded data is read.

key

A list containing a field size that indicates how many bytes of data to process.

endian

A character string specifying the byte order; either "big" or "little". The default is "big".

Value

An integer vector containing the decoded numbers.

Details

0x9C

Read 4 bytes as an unsigned 32-bit integer.

0x94

Read one count byte, then (count+1) unsigned 32-bit integers.

0xAC

Read 3 bytes as a 24-bit signed integer; add its value to the current tracking value.

0xA4

Read one count byte, then (count+1) 24-bit signed integers; sequentially add each to the tracking value.

0x89

Read 1 byte as a signed 8-bit integer; add it to the tracking value.

0x8A

Read 2 bytes as a signed 16-bit integer; add it to the tracking value.

0x82

Read one count byte, then (count+1) signed 16-bit integers; sequentially add each to the tracking value.

0x81

Read one count byte, then (count+1) signed 8-bit integers; sequentially add each to the tracking value.

A 24-bit signed integer is computed by reading 3 bytes and then adjusting the value by subtracting 16777216 if the computed value is greater than or equal to 8388608 to account for the two's complement representation.