Package kenozooid :: Package driver :: Package hwos :: Module parser

Module parser

source code

Data parser for hwOS family OSTC dive computers driver.
Classes
  EventFlags
Event flags.
Functions
 
raw_data(data) source code
 
parse_dives(data) source code
 
parse_profile(header, data)
Parse dive profile raw data.
source code
 
get_first_gas(header)
Get first gas from dive header.
source code
 
parse_events(data)
Parse event data from event bytes of dive profile sample raw data.
source code
 
parse_event_data(events, data)
Parse event data from a raw data of a sample of a dive profile.
source code
 
create_extended_data_parsers(profile_header)
Create iterator of parsers for dive profile extended data.
source code
 
create_extended_data_parser(profile_header, sample_no)
Create extended data parser for a specific dive profile sample.
source code
 
model_version(data)
Get model and version information about a hwOS family OSTC dive computer.
source code
 
parse_header(data)
Parse dive header data read from hwOS OSTC dive computer.
source code
 
parse_profile_header(data)
Parse dive profile header (aka small header).
source code
 
dive_profile_size(data)
Extract dive profile size from dive header raw data.
source code
 
dive_headers_data(headers)
Divide all dive header raw data into collection of raw data for each header.
source code
 
header_fields(parsers, fmt, data)
Extract dive header fields data from dive header raw data.
source code
 
dive_profile_sample_idx(data)
Determine index of each dive profile sample using the profile raw data.
source code
 
dive_profile_next_sample(data, idx, sample_no)
Calculate index of next dive profile sample.
source code
 
partition(data, *idx)
Partition the data using indexes.
source code
 
create_dive(header, data)
Create Kenozooid dive record.
source code
 
create_sample(header, profile_header, ext_parser, sample_no, data)
Create Kenozooid dive profile sample record.
source code
Variables
  logger = logging.getLogger(__name__)
  COMMANDS = b'\x69', 64, (b'\x60', 5), (b'\x61', 65536),
  MODEL = {0x0a: 'OSTC 3', 0x1a: 'OSTC 3+', 0x05: 'OSTC cR', 0x0...
  DIVE_MODES = 'opencircuit', 'closedcircuit', 'opencircuit', 'a...
  MIN_SAMPLE_SIZE = 3
  EVENT_DATA_SIZE = 2, 1, 1, 2
  GAS_TYPE_DISABLED = 0
  GAS_TYPE_FIRST = 1
  UNPACK_GAS_MIX = struct.Struct('<BB').unpack
  UNPACK_DECO = struct.Struct('<BB').unpack
  RawData = namedtuple('Data', ['version', 'features', 'headers'...
  Header = namedtuple('Header', ['size', 'datetime', 'depth', 'd...
  ProfileHeader = namedtuple('ProfileHeader', ['size', 'rate', '...
  Divisor = namedtuple('Divisor', ['type', 'size', 'divisor'])
  Events = namedtuple('Events', ['alarm', 'events'])
  EventData = namedtuple('EventData', ['manual_gas', 'gas', 'set...
  to_int = partial(int.from_bytes, byteorder= 'little', signed= ...
  to_timestamp = lambda v:
  to_depth_adj = lambda v:
  to_depth = lambda v:
  to_duration = lambda v:
  to_temp = lambda v:
  to_gas = lambda v:
  to_gas_list = lambda data:
Function Details

parse_profile(header, data)

source code 
Parse dive profile raw data.
Parameters:
  • header - Dive header.
  • data - Dive profile raw data.

get_first_gas(header)

source code 

Get first gas from dive header.

If there is no first gas configured, then pick first non-disabled gas.

parse_events(data)

source code 
Parse event data from event bytes of dive profile sample raw data.
Parameters:
  • data - Dive profile sample raw data.

parse_event_data(events, data)

source code 
Parse event data from a raw data of a sample of a dive profile.
Parameters:
  • events - Event flags.
  • data - Raw data of a sample of a dive profile.

create_extended_data_parsers(profile_header)

source code 

Create iterator of parsers for dive profile extended data.

Dive profile samples contains variable amount of extended data and require a specific parser.

Parameters:
  • profile_header - Dive profile header.

create_extended_data_parser(profile_header, sample_no)

source code 

Create extended data parser for a specific dive profile sample.

Divisor information is used to determine how data should be parsed for given dive profile sample number.

Parameters:
  • profile_header - Dive profile header.
  • sample_no - Dive profile sample number.

model_version(data)

source code 

Get model and version information about a hwOS family OSTC dive
computer.

:param data: Raw data fetched from a hwOS family OSTC dive computer.

.. seealso:: `RawData`

parse_profile_header(data)

source code 
Parse dive profile header (aka small header).
Parameters:
  • data - Dive profile data.

dive_headers_data(headers)

source code 
Divide all dive header raw data into collection of raw data for each header.
Parameters:
  • headers - Raw header data fetched from hwOS OSTC dive computer.

header_fields(parsers, fmt, data)

source code 
Extract dive header fields data from dive header raw data.
Parameters:
  • parsers - Parser for each field, including start and end markers.
  • fmt - Struct format to extract the fields.
  • data - Dive header raw data.

dive_profile_sample_idx(data)

source code 
Determine index of each dive profile sample using the profile raw data.
Parameters:
  • data - Dive profile raw data.

dive_profile_next_sample(data, idx, sample_no)

source code 

Calculate index of next dive profile sample.

The calculation is performed using dive profile raw data and index of current dive profile sample. The idx + 2 points to profile flag byte, which is used to determine total length of current sample.

Parameters:
  • data - Dive profile raw data.
  • idx - Index of current dive profile sample.
  • sample_no - Sample number (unused).

partition(data, *idx)

source code 

Partition the data using indexes.

Each index is start of each item.

Parameters:
  • data - Data to partition.
  • idx - Indexes used to partition the data.

create_dive(header, data)

source code 
Create Kenozooid dive record.
Parameters:
  • header - Dive header of a dive stored in hwOS OSTC dive computer.
  • data - Dive profile raw data.

create_sample(header, profile_header, ext_parser, sample_no, data)

source code 
Create Kenozooid dive profile sample record.
Parameters:
  • header - Dive header.
  • profile_header - Dive profile header.
  • ext_parser - Extended information parser.
  • sample_no - Dive profile sample number.
  • data - Dive profile sample data.

Variables Details

MODEL

Value:
{0x0a: 'OSTC 3', 0x1a: 'OSTC 3+', 0x05: 'OSTC cR', 0x07: 'OSTC cR', 0x\
12: 'OSTC Sport', 0x11: 'OSTC 2', 0x13: 'OSTC 2', 0x1b: 'OSTC 2',}

DIVE_MODES

Value:
'opencircuit', 'closedcircuit', 'opencircuit', 'apnoe'

RawData

Value:
namedtuple('Data', ['version', 'features', 'headers', 'profiles'])

Header

Value:
namedtuple('Header', ['size', 'datetime', 'depth', 'duration', 'temp',\
 'gas_list', 'avg_depth', 'mode'],)

ProfileHeader

Value:
namedtuple('ProfileHeader', ['size', 'rate', 'divs'])

EventData

Value:
namedtuple('EventData', ['manual_gas', 'gas', 'setpoint', 'bailout'])

to_int

Value:
partial(int.from_bytes, byteorder= 'little', signed= False)